"파이썬 for"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
3번째 줄: 3번째 줄:
;파이썬 for
;파이썬 for


<syntaxhighlight lang='python'>
<syntaxhighlight lang='python' run>
for looper in range(3):
for x in range(3):
     print("Hello")
     print("Hello")
# Hello
# Hello
# Hello
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='Python'>
<syntaxhighlight lang='Python' run>
for i in range(4):
for i in range(4):
  print(i)
    print(i)
# 0
# 1
# 2
# 3
</syntaxhighlight>
</syntaxhighlight>
{{소스헤더|문자열}}
{{소스헤더|문자열}}
<syntaxhighlight lang='python'>
<syntaxhighlight lang='python' run>
for x in 'cat':
for x in 'cat':
     print(x)
     print(x)
# c
# a
# t
</syntaxhighlight>
</syntaxhighlight>
{{소스헤더|튜플}}
{{소스헤더|튜플}}
<syntaxhighlight lang='Python'>
<syntaxhighlight lang='Python' run>
for word in ('Alice', 'Bob', 'Carol'):
for word in ('Alice', 'Bob', 'Carol'):
  print('Hello, %s' % word)
    print('Hello, %s' % word)
# Hello, Alice
# Hello, Bob
# Hello, Carol
</syntaxhighlight>
</syntaxhighlight>
{{소스헤더|리스트}}
{{소스헤더|리스트}}
<syntaxhighlight lang='Python'>
<syntaxhighlight lang='Python'>
for word in ['Alice', 'Bob', 'Carol']:
for word in ['Alice', 'Bob', 'Carol']:
  print('Hello, %s' % word)
    print('Hello, %s' % word)
# Hello, Alice
# Hello, Bob
# Hello, Carol
</syntaxhighlight>
</syntaxhighlight>



2021년 10월 4일 (월) 19:20 판

1 개요

Python for
파이썬 for
for x in range(3):
    print("Hello")
for i in range(4):
    print(i)
문자열
for x in 'cat':
    print(x)
튜플
for word in ('Alice', 'Bob', 'Carol'):
    print('Hello, %s' % word)
리스트
for word in ['Alice', 'Bob', 'Carol']:
    print('Hello, %s' % word)

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}