01_Python
37_제어문>for반복문과 딕셔너리 조합
chuuvelop
2025. 1. 8. 21:55
728x90
01. for반복문과 딕셔너리 조합
- for반복문과 딕셔너리를 조합하면 딕셔너리의 키가 변수로 들어감
dict1 = {"name" : "건조 망고",
"type" : "당 절임",
"ingredient" : ["망고", "설탕", "나트륨", "색소"],
"origin" : "필리핀"}
for key in dict1:
print(key)
print(dict1[key])
print("-" * 10)
name
건조 망고
----------
type
당 절임
----------
ingredient
['망고', '설탕', '나트륨', '색소']
----------
origin
필리핀
----------
dict1["name"]
'건조 망고'
728x90