Guidelines

νŒŒμ΄μ¬μ—μ„œ 쑰건에 따라 λ°˜λ³΅μ„ μˆ˜ν–‰ν•˜λŠ” 방법

for λ°˜λ³΅λ¬Έμ€ λ¦¬μŠ€νŠΈλ‚˜ νŠœν”Œ 같은 일련의 ν•­λͺ©λ“€μ„ μ°¨λ‘€λŒ€λ‘œ μ‚΄νŽ΄λ³΄λ©΄μ„œ, 각 ν•­λͺ©μ— λŒ€ν•΄ λ™μΌν•œ μž‘μ—…μ„ λ°˜λ³΅ν•΄μ„œ μˆ˜ν–‰ν•  λ•Œ μ‚¬μš©ν•©λ‹ˆλ‹€.

μ—¬κΈ°μ„œ 리슀트, νŠœν”Œ, λ¬Έμžμ—΄ 등을 μ‹œν€€μŠ€(Sequence)라고 λΆ€λ₯΄λ©°, μ‹œν€€μŠ€μ˜ 각 ν•­λͺ©μ„ μš”μ†Œ(Element)라고 λΆ€λ¦…λ‹ˆλ‹€.


for 반볡문 ꡬ쑰

for λ°˜λ³΅λ¬Έμ€ for ν‚€μ›Œλ“œλ‘œ μ‹œμž‘ν•˜λ©°, λ°˜λ³΅ν•  각 μš”μ†Œλ₯Ό λ‚˜νƒ€λ‚΄λŠ” λ³€μˆ˜μ™€ μˆœνšŒν•  μ‹œν€€μŠ€λ₯Ό μ§€μ •ν•©λ‹ˆλ‹€.

for 반볡문 ꡬ쑰
for μš”μ†Œ in μ‹œν€€μŠ€: λ°˜λ³΅ν•΄μ„œ μˆ˜ν–‰ν•  μ½”λ“œ

μ‹œν€€μŠ€ μ•ˆμ— μžˆλŠ” 각 μš”μ†Œλ“€μ΄ μ°¨λ‘€λŒ€λ‘œ μš”μ†ŒλΌλŠ” λ³€μˆ˜μ— λŒ€μž…λ˜λ©°, λ°˜λ³΅ν•΄μ„œ μˆ˜ν–‰ν•  μ½”λ“œκ°€ μ‹€ν–‰λ©λ‹ˆλ‹€.

μ‹œν€€μŠ€ λ§ˆμ§€λ§‰μ—λŠ” 콜둠(:)을 λΆ™μ—¬μ•Ό ν•˜λ©°, λ°˜λ³΅ν•΄μ„œ μˆ˜ν–‰ν•  μ½”λ“œλŠ” λ°˜λ“œμ‹œ λ“€μ—¬μ“°κΈ°λ₯Ό ν•΄μ•Ό ν•©λ‹ˆλ‹€.


for 반볡문 μ˜ˆμ‹œ

μ•„λž˜ for 반볡문 μ˜ˆμ‹œλŠ” numbersλΌλŠ” 리슀트의 각 μš”μ†Œλ₯Ό μ°¨λ‘€λŒ€λ‘œ num λ³€μˆ˜μ— λŒ€μž…ν•˜κ³ , num λ³€μˆ˜λ₯Ό 좜λ ₯ν•˜λŠ” μ½”λ“œμž…λ‹ˆλ‹€.

for 반볡문 μ˜ˆμ‹œ
numbers = [1, 2, 3, 4, 5] for num in numbers: # numbers 리슀트의 각 μš”μ†Œλ₯Ό μ°¨λ‘€λŒ€λ‘œ num λ³€μˆ˜μ— λŒ€μž… print(num) # num λ³€μˆ˜λ₯Ό 좜λ ₯ # 1, 2, 3, 4, 5κ°€ ν•œ 쀄씩 좜λ ₯됨

Guidelines

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Execution Result