Module 5

Dictionary keys and values

Accessing all keys or values.

Exploring a dictionary

You can get all the keys, all the values, or all the pairs from a dictionary.

Python
sample = {"id": "Tv01", "length": 499}
print(sample.keys())
print(sample.values())
dict_keys(['id', 'length']) dict_values(['Tv01', 499])
Your task

Access keys and values

  • Print the keys and values of the dictionary.