Programming is a humbling experience. Seemingly simple things will often surprise you, they’re not so trivial after all. One such example is the string to list conversion. In this article, you’ll learn everything you need to know to convert a string to a list—in different contexts and using different methods.
MethodDescriptionlist(string)Break a string into a list of characters.[c for c in string]List comprehension for simple character modifications.lst = ; for c in string: lst.append(c)For more complicated character modifications.string.split()To break the string into arbitrary substrings using a delimiter.
Problem: Given a string such as ‘hello world’. How to convert it to a list