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() ?
splitsplits a string based on a delimiter string. By default the delimiter string it uses is a space. Since there are no spaces in your string, no delimters of any kind really,splitis stymied. "List-ifying" your string as Andrej shows in his answer is the right way to go in this case.