Question about lists | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Question about lists

How can I make a list from given strings without spaces? ex: string='hey hi' my_list=list[string] then my_list will be ['h', 'e', 'y', ' ', 'h', 'i']

13th Dec 2018, 1:45 PM
최호준
1 Antwort
+ 5
Hi 최호준 You want to make a list of the characters in your string? Just use the list() function: my_string = "spam" my_list = list(my_string) print(my_list) # Output: ['s', 'p', 'a', 'm'] Hope that helps :)
13th Dec 2018, 1:50 PM
Kishalaya Saha
Kishalaya Saha - avatar