get string as list python code example
Example 1: string to list python
s = 'hello'
l = list(s)
print(l) # prints ['h', 'e', 'l', 'l', 'o']
Example 2: python string to tuple
l = list('abcd') # ['a', 'b', 'c', 'd']
l = map(None, 'abcd') # ['a', 'b', 'c', 'd']
l = [i for i in 'abcd'] # ['a', 'b', 'c', 'd']
import re # importing regular expression module
l = re.findall('.', 'abcd')
print(l) # ['a', 'b', 'c', 'd']