중첩된 딕셔너리
Coddy Python 여정의 논리와 흐름 섹션에 포함된 레슨. 78개 중 13번째.
nested dictionary는 dictionary 안에 있는 dictionary입니다. 이를 통해 복잡한 data 구조를 구성하여 관련 정보를 더 쉽게 다룰 수 있습니다.
예시:
students = {
"Alice": {"age": 20, "grade": "A"},
"Bob": {"age": 22, "grade": "B"}
}
# Accessing a nested value
print(students["Alice"]["age"]) # Output: 20
# Adding a new key-value pair to a nested dictionary
students["Alice"]["major"] = "Math"
print(students["Alice"]) # Output: {'age': 20, 'grade': 'A', 'major': 'Math'}중첩 dictionary는 students, employees 또는 products에 대한 세부 정보 저장과 같이 관련 정보를 함께 그룹화해야 할 때 유용합니다.
직접 해보기
이 레슨에는 코드 챌린지가 없습니다.
이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.
논리와 흐름의 모든 레슨
직접 연습해 보세요: 온라인 Python 컴파일러