How to split string into list of characters in Python

2 Answers

0 votes
def getCharList(s):
	return [ch for ch in s]

s = 'python'

print(getCharList(s))
 
 
 
'''
run:
 
['p', 'y', 't', 'h', 'o', 'n']
 
'''

 



answered Oct 26, 2020 by avibootz
0 votes
s = 'python'

lst = list(s)

print(lst)
 
 
 
'''
run:
 
['p', 'y', 't', 'h', 'o', 'n']
 
'''

 



answered Oct 26, 2020 by avibootz

Related questions

1 answer 259 views
2 answers 232 views
2 answers 244 views
2 answers 168 views
2 answers 215 views
...