+ 3

Problem with split in python

how can i do something like ''abcde'' = [''a'', ''b'', ''c'', ''d'', ''e''] in python? if i do ''abcde''.split('''') it says empty separator

9th May 2018, 11:34 AM
Etabeta1🇮🇹
Etabeta1🇮🇹 - avatar
2 Réponses
+ 4
Just use: my_list = list('abcde')
9th May 2018, 11:40 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
split() is for splitting strings with a character between each one. If you need to split a string into its individual characters, use list() instead. Example when typed into live session: >>> list("abcde") ['a', 'b', 'c', 'd', 'e']
9th May 2018, 11:43 AM
apex137
apex137 - avatar