2021-03-27

Why is split() not separating each character in a string in the list output?

for the following split() function in Python:

hallway = "<--<--->->"

list_string = hallway.split()

print(list_string)

The output that I am getting is ["<--<--->->"] but my desired output is ["<","-","-","<","-","-","-",">","-",">"]

Can someone please explain why my code is not producing the desired output? And how can I product the desired output simply using split() ?



from Recent Questions - Stack Overflow https://ift.tt/2P38JVX
https://ift.tt/eA8V8J

No comments:

Post a Comment