티스토리 뷰

Ongoing/String

for [Python] string

More Code 2018. 6. 20. 17:03


# 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
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함