How to convert a dictionary into a list of tuples in Python #shorts

preview_player
Показать описание
Converting a dictionary into a list of tuples creates a list that contains each key-value pair in the dictionary as a tuple. For example, converting the dictionary {"a": 1, "b": 2, "c": 3} into a list of tuples results in [("a", 1), ("b", 2), ("c", 3)].

#ytshorts #python #tuplesinpython #pythontuples #dictionary
Рекомендации по теме
Комментарии
Автор

thank you so much i was sitting here googling for a solid hour

sked
Автор

can't you just do:

l = [items for items in a_dictionary]
h = tuple(l)

koalakid
visit shbcf.ru