07-25-2023, 10:38 AM
my_dict = {'a': 1, 'b': 2, 'c': 3}
# Dictionary view for keys
keys_view = my_dict.keys()
print(keys_view) # Output: dict_keys(['a', 'b', 'c'])
# Dictionary view for values
values_view = my_dict.values()
print(values_view) # Output: dict_values([1, 2, 3])
# Dictionary view for items (key-value pairs)
items_view = my_dict.items()
print(items_view) # Output: dict_items([('a', 1), ('b', 2), ('c', 3)])
# Dictionary view for keys
keys_view = my_dict.keys()
print(keys_view) # Output: dict_keys(['a', 'b', 'c'])
# Dictionary view for values
values_view = my_dict.values()
print(values_view) # Output: dict_values([1, 2, 3])
# Dictionary view for items (key-value pairs)
items_view = my_dict.items()
print(items_view) # Output: dict_items([('a', 1), ('b', 2), ('c', 3)])