Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tuple to dict

t = (1, 2)
d = dict([t])
Comment

python tuple to dict

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

dict to tuple

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

PREVIOUS NEXT
Code Example
Python :: #find the difference in days between two dates. 
Python :: list in python 
Python :: Difference between append() and extend() method in Python 
Python :: how to add one to a variable in python 
Python :: Subset data frame by date 
Python :: python regex validate phone number 
Python :: python new line 
Python :: convert number to reversed array of digits python 
Python :: print on same line 
Python :: os dir exists 
Python :: extract address from text python 
Python :: pip config proxy 
Python :: tkinter add text to canvas 
Python :: list functions 
Python :: IndexError: invalid index to scalar variable. 
Python :: Install Pip 2 on ubuntu linux 
Python :: how list ul li with python scraping 
Python :: re module documentation 
Python :: telegram.ext package python 
Python :: fast way to load mongodb data into python list 
Python :: python puissance 
Python :: how to stop auto log writing by other function in python 
Python :: MNIST model 
Python :: torch distributed address already in use 
Python :: Code Example of Hashmap in Python 
Python :: matplotlib ax.annotate color of the arrow 
Python :: change background create_text tkinter 
Python :: dataframe concatenate 
Python :: pandas sequential numbering within group 
Python :: cv2 remove black borders on images 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =