개발 => 복습 후 재정리 대기/Python

[Python][문법] list + dictionary

장 상 현 2021. 5. 5.
people = [
     {'name' : 'bob', 'age' : 27},
     {'name' : 'jang', 'age' : 34}
]

print(people[1]['age']) # 34





people = [
     {'name': 'bob', 'age': 20, 'score':{'math':90,'science':70}},
     {'name': 'carry', 'age': 38, 'score':{'math':40,'science':72}},
     {'name': 'smith', 'age': 28, 'score':{'math':80,'science':90}},
     {'name': 'john', 'age': 34, 'score':{'math':75,'science':100}}
]

print(people[2]['score']['science']) # 90

people = [
     {'name' : 'bob', 'age' : 27},
     {'name' : 'jang', 'age' : 34}
]

print(people[1]['age']) # 34

 

 

people = [
     {'name': 'bob', 'age': 20, 'score':{'math':90,'science':70}},
     {'name': 'carry', 'age': 38, 'score':{'math':40,'science':72}},
     {'name': 'smith', 'age': 28, 'score':{'math':80,'science':90}},
     {'name': 'john', 'age': 34, 'score':{'math':75,'science':100}}
]

print(people[2]['score']['science']) # 90

댓글