“Python tuple to Dict” Kod odpowiedzi

Python tuple to Dict

>>> t = ((1, 'a'),(2, 'b'))
>>> dict((y, x) for x, y in t)
{'a': 1, 'b': 2}
The Biton

Dict to Tuple

dict = { 'Geeks': 10, 'for': 12, 'Geek': 31 }
# Converting into list of tuple
list = [(k, v) for k, v in dict.items()]
Foolish Flatworm

Odpowiedzi podobne do “Python tuple to Dict”

Pytania podobne do “Python tuple to Dict”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu