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 test type 
Python :: how to compare values in dictionary with same key python 
Python :: form action in django 
Python :: python codes 
Python :: image blur in python 
Python :: histogram seaborn python 
Python :: hash python png 
Python :: how to check how many digits string has in python 
Python :: get file parent directory python 
Python :: dataframe pandas empty 
Python :: flatten a list 
Python :: scrape email in a list from website python 
Python :: read ms word with python 
Python :: raspistill timelapse 
Python :: replace characters in string python 
Python :: calculate pointbiseral correlation 
Python :: colon in array python 
Python :: python PyDrive service account credentials 
Python :: Python - How To Count Occurrences of a Character in a String 
Python :: conda enviroment python version 
Python :: sum of array in python 
Python :: how to convert integer to binary string python 
Python :: django trim string whitespace 
Python :: how to run flask in port 80 
Python :: panda python 
Python :: numpy scale array 
Python :: python socket get client ip 
Python :: find all unique substring permutations of a string of a specific length python 
Python :: python sort algorithm 
Python :: xlabel font type matplotlib 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =