Loop through list of tuples python

Code examples

0
0

python array of tuples for loop

coordinates = [(0,0),(0,3),(1,0),(1,2),(1,3)]

for (i,j) in coordinates:
    print i,j
0
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

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................