μ€μ²© 리μ€νΈμ μ€μ²© λ°λ³΅λ¬Έ
μ€μ²©(Nested) 리μ€νΈλ 리μ€νΈ λ΄λΆμ λ€λ₯Έ 리μ€νΈλ₯Ό ν¬ν¨νλ ꡬ쑰λ₯Ό λ§ν©λλ€.
μ€μ²© λ°λ³΅λ¬Έμ μ΄λ¬ν μ€μ²© 리μ€νΈλ₯Ό μννκΈ° μν΄ μ¬μ©λλ©°, μ£Όλ‘ λ°μ΄ν° μ²λ¦¬μ μκ³ λ¦¬μ¦ κ΅¬ν λ±μ νμ©λ©λλ€.
μ€μ²© 리μ€νΈμ μ¬μ©
μ€μ²© 리μ€νΈλ νλ ¬(matrix), ν(table), λ€μ°¨μ λ°μ΄ν° ꡬ쑰 λ±μ ννν λ μ¬μ©ν©λλ€.
μ€μ²© 리μ€νΈ μμ
# 3x3 νλ ¬ matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]
μ€μ²© λ°λ³΅λ¬Έμ νμ©
μ€μ²© λ°λ³΅λ¬Έμ μ¬μ©νμ¬ μ€μ²© 리μ€νΈμ κ° μμμ μ κ·Όν μ μμ΅λλ€.
μλ 2μ€ for λ¬Έμμ μΈλΆ λ°λ³΅λ¬Έμ 리μ€νΈμ ν(κ°λ‘μ΄)μ, λ΄λΆ λ°λ³΅λ¬Έμ κ° νμ μμλ₯Ό μνν©λλ€.
μ€μ²© λ°λ³΅λ¬Έ μμ
# 3x3 νλ ¬ λ΄ μμ μΆλ ₯ matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] for row in matrix: # ν μν for item in row: # ν λ΄ μμ μν print(item) # 1, 2, 3, 4, 5, 6, 7, 8, 9κ° ν μ€μ© μΆλ ₯λ¨
Guidelines
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help
Code Editor
Run
Generate
Execution Result