Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

loop through list of tuples python

list_of_tuples = [("Betty", 45), ("John" , 84), ("Malik" , 34), ("Jose" , 20)]


for index, tuple in enumerate(list_of_tuples):
  
	element_one = tuple[0]
	element_two = tuple[1]

	print('Index:', index, element_one, element_two)

>>> Index: 0 Betty 45
	Index: 1 John 84
	Index: 2 Malik 34
	Index: 3 Jose 20
Comment

iterate a list of tuples

#listOfTuples =  [("hello", 1)]
for k, v in listOfTuples:
	print(k , v)
#output : hello 1
Comment

python iterate over tuple of lists

tuple_list = ([1,2,3], ['label1', 'label2', 'label3'])
for val, label in zip(*tuple_list):
     print(val, label)
Comment

PREVIOUS NEXT
Code Example
Python :: python ascii() 
Python :: run python script task scheduler 
Python :: get index of item in list 
Python :: python if column is null then 
Python :: better way to see full csv in jupyter notebook 
Python :: how to check for updates from github in python 
Python :: Plot kdeplot, lineplot, scatterplot in seaborn 
Python :: Dictionary get both key and value. 
Python :: signup class 
Python :: how to connect ip camera to opencv python 
Python :: how to loop through every character in a string 
Python :: streamlit format_func example 
Python :: NumPy left_shift Syntax 
Python :: declare array python 
Python :: how to stop python for certain time in python 
Python :: django pass list of fields to values 
Python :: seaborn heatmap center xticks 
Python :: array slicing python 
Python :: python django adding category 
Python :: sum of fraction numbers in python 
Python :: how to create tupple in python 
Python :: NumPy resize Syntax 
Python :: gpu DBSCAN python 
Python :: django convert model to csv 
Python :: python add new key to dictionary 
Python :: python selenium teardown class 
Python :: pandas groupby 
Python :: python download images from unsplash 
Python :: change folder name python 
Python :: get coordinates of an image from a pdf python 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =