Horje
loop through list of tuples python Code Example
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
Source: www.kite.com
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
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




Python

Related
sort dictionary by values Code Example sort dictionary by values Code Example
how to sort a list descending python Code Example how to sort a list descending python Code Example
python3 ngrok.py Code Example python3 ngrok.py Code Example
timedelta Code Example timedelta Code Example
how to print stdout while processing the execution in python Code Example how to print stdout while processing the execution in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7