Python Programming with Corey Schafer_Notes_5
Python Programming with Corey Schafer_Notes_5
Lecture 5 - Dictionaries
• Key value pairs ar two linked values where key is the unique identifier of data and the value is
the data
• Represent a student using a dictionary ( ‘:’ is used to separate key from the value)
student = {"name" : "John", "age" : "25", "courses" : ["Maths", "English"]}
print(student)
→ {'name': 'John', 'age': '25', 'courses': ['Maths', 'English']}
• Values in dictionary can be anything i.e. name is string, age is integer and courses is list
• Delete a key from the dictionary using pop method (popped value can also be used)
student = {"name" : "John", "age" : "25", "courses" : ["Maths", "English"]}
age = student.pop ('age')
print(student)
print(age)
→ {'name': 'John', 'courses': ['Maths', 'English']}
25