In [15]:
student = { 'Name' : 'Michael', 'GPA': 3.2, 'Ischool' : True }
print(student)
In [16]:
# KeyError, keys must match exactly
student['gpa']
In [17]:
try:
print(student['Age'])
except KeyError:
print('The key "Age" does not exist.')
In [18]:
list(student.values())
Out[18]:
In [19]:
list(student.keys())
Out[19]:
In [20]:
for key in student.keys():
print(student[key])
In [21]:
del student['GPA']
print(student)