본문 바로가기

Ongoing/String

for [Python] string


# Python 3

words = 'Python'

for c in words:
print(c)

""" Output
P
y
t
h
o
n
"""



# Python 3

words = 'Python'

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

""" Output
0 P
1 y
2 t
3 h
4 o
5 n
"""



# Python 3

words = 'Python'

for i, c in enumerate(words):
print(i, c)

""" Output
0 P
1 y
2 t
3 h
4 o
5 n
"""


'Ongoing > String' 카테고리의 다른 글

[C#] Composite Format String & Interpolated String  (0) 2018.07.09
for [C/C++] char[] string  (0) 2018.06.21
for [Java] String  (0) 2018.06.20
for foreach [C#] string  (0) 2018.06.20
IO Functions [C] Character & String  (0) 2018.06.15