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

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
Comment

PREVIOUS NEXT
Code Example
Python :: pygame keys keep pressing 
Python :: run python version from terminal 
Python :: k fold cross validation from scratch python 
Python :: create python dataframe 
Python :: python windows os.listdir path usage 
Python :: python time 
Python :: python random uuid 
Python :: Append a line to a text file using the write() function 
Python :: python breadth first search 
Python :: how to set global variable in python function 
Python :: repeat rows in a pandas dataframe based on column value 
Python :: join in pathlib path 
Python :: python delete from dictionary pop 
Python :: adding strings together 
Python :: send xml data with python 
Python :: python merge two array into one 
Python :: py virtual 
Python :: how to submit two forms in django 
Python :: python how to replace a string in a list 
Python :: rename rows pandas based on condiions 
Python :: python read from stdin pipe 
Python :: python save plot 
Python :: text color python tkinter 
Python :: python set to list 
Python :: python program to reverse a list 
Python :: download maptolib 
Python :: pandas series add word to every item in series 
Python :: log in python 
Python :: Python Alphabet using list comprehension 
Python :: python kiwi install 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =