How to split string into char array in Python

4 Answers

0 votes
s = 'python'

lst = list(s)

print(lst)



'''
run:

['p', 'y', 't', 'h', 'o', 'n']

'''

 



answered Apr 14, 2021 by avibootz
0 votes
s = 'python'

lst = []

lst.extend(s)

print(lst)



'''
run:

['p', 'y', 't', 'h', 'o', 'n']

'''

 



answered Apr 14, 2021 by avibootz
0 votes
s = 'python'

lst = [*s]

print(lst)



'''
run:

['p', 'y', 't', 'h', 'o', 'n']

'''

 



answered Apr 14, 2021 by avibootz
0 votes
s = 'python'

lst = [ch for ch in s]

print(lst)



'''
run:

['p', 'y', 't', 'h', 'o', 'n']

'''

 



answered Apr 14, 2021 by avibootz

Related questions

...