How to loop over string characters in Python

2 Answers

0 votes
s ='python'

for ch in s:
    print(ch)

 
 
'''
run:
 
p
y
t
h
o
n
 
'''

 



answered Jan 17, 2020 by avibootz
0 votes
s ='python'

for i in range(0, len(s)):
    print(s[i])

 
 
'''
run:
 
p
y
t
h
o
n
 
'''

 



answered Jan 17, 2020 by avibootz

Related questions

1 answer 147 views
1 answer 140 views
2 answers 247 views
1 answer 195 views
1 answer 191 views
...