choco's story

파이썬 스터디 28 - items() 함수 본문

프로그래밍 언어 공부 (Coding Study)/파이썬 (Python) 기본

파이썬 스터디 28 - items() 함수

초코choco 2024. 9. 20. 16:30

items() 함수

키(Key)값(Value)을 동시에 얻을 수 있는 함수

기본구조

for 키, 값 in [딕셔너리 이름].items():
     코드

ex)

example_dict = {
    "A": "a",
    "B": "b",
    "C": "c"
    }

example_dict.items()

for key, element in example_dict.items():
    print("dict[{}] = {}".format(key, element))

출력결과