convert string to array python

how to convert string to char in python?

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

# To split the string at a specific character use the split() function
word = 'l,o,v'
L = word.split(',')
L
# 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' ]

convert string list to list python

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

Leave a Comment