Answers for "python iterate list with tuples"

0

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
Posted by: Guest on May-17-2021
0

iterate a list of tuples

#for [("hello", 1)...]
#using the dict() method
for k, v on dict(listOfTuples).items():
	print(k , v)
#output : hello 1
Posted by: Guest on October-09-2021

Python Answers by Framework

Browse Popular Code Answers by Language