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

[Python][문법] Dictionary

장 상 현 2021. 5. 5.
a_dict = {'name' : 'bob', 'age' : 34, 'friend' : ['영희', '철수']}

result = a_dict['name']

print(result) # bob


result = a_dict['friend'][1]

print(result) # 철수


a_dict['height'] = 180

print(a_dict) # {'name': 'bob', 'age': 34, 'friend': ['영희', '철수'], 'height': 180}

print('height' in a_dict) # True

a_dict = {'name' : 'bob', 'age' : 34, 'friend' : ['영희', '철수']}

result = a_dict['name']

print(result) # bob


result = a_dict['friend'][1]

print(result) # 철수


a_dict['height'] = 180

print(a_dict) # {'name': 'bob', 'age': 34, 'friend': ['영희', '철수'], 'height': 180}

print('height' in a_dict) # True

댓글