Dictionary views in Python 3 - Printable Version +- QP School (https://qomplainerzschool.lima-city.de) +-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3) +--- Forum: Python 3 Tutorials and examples (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=51) +--- Thread: Dictionary views in Python 3 (/showthread.php?tid=5066) |
Dictionary views in Python 3 - Qomplainerz - 07-25-2023 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)]) |