+ 3

Why string.split() doesn't work here !

string = 'abc' lst = string.split("") print(lst) Why this shows error?

13th Jun 2020, 8:22 AM
Andrina
6 Answers
+ 5
You can also directly use list function... String="abc" Lst=list(String)
13th Jun 2020, 8:57 AM
ANJALI SAHU
+ 3
You can't have empty string in split function. If you want each letter seperated you should try " ".join("abc") which will return a b c If you want each letter separated inside list you should try " ".join("abc").split(" ") which will return. ["a","b","c"] Hope It Helps You!
13th Jun 2020, 8:32 AM
Hacker Badshah
Hacker Badshah - avatar
+ 3
13th Jun 2020, 8:37 AM
Andrina
+ 2
Mirielle ohk thanks...!
13th Jun 2020, 8:37 AM
Andrina