How to split a string into array (list) of characters in Python

2 Answers

0 votes
s = "python c++ java c#"

l = list(s)

print(l)


'''
run:

['p', 'y', 't', 'h', 'o', 'n', ' ', 'c', '+', '+', ' ', 'j', 'a', 'v', 'a', ' ', 'c', '#']

'''

 



answered Jun 19, 2017 by avibootz
0 votes
s = "python c++ java c#"

l = list(s)

for char in l:
    print(char)


'''
run:

p
y
t
h
o
n

c
+
+

j
a
v
a

c
#

'''

 



answered Jun 19, 2017 by avibootz

Related questions

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