convert string to array python

Rate this post

how to convert string to char in python?

# To split the string at every character use the list() function
word = 'lov'
L = list(word)
# Output:
# ['l', 'o', 'v']

# To split the string at a specific character use the split() function
word = 'l,o,v'
L = word.split(',')
# Output:
# ['l', 'o', 'v']

Also Read: python line count
convert string to list of characters python
>>> text = 'p a k'
>>> text = text.split(' ')
>>> text
[ 'p', 'a', 'k' ]

Free Live Chat for Any Issue

convert string list to list python

s = 'jayde'
l = list(s)
print(l) # prints ['j', 'a', 'y', 'd', 'e']