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 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

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 :: find the factorial of a given integer in python 
Python :: replace all nan values in dataframe 
Python :: python get attributes of class 
Python :: python reverse words in string 
Python :: pytorch get gpu number 
Python :: generate n different random numbers python 
Python :: how to unique list in python 
Python :: selenium webdriver manager python 
Python :: how to use the print function in python 
Python :: open and read a file in python 
Python :: get sum from x to y in python 
Python :: int to string python 
Python :: get all file in folder python 
Python :: how to add mouse button in pygame 
Python :: python merge two dictionaries in a single expression 
Python :: what value do we get from NULL database python 
Python :: python returen Thread 
Python :: get mac address python 
Python :: fizzbuzz python solution 
Python :: resto division python 
Python :: python assert 
Python :: how can i make a list of leftovers that are str to make them int in python 
Python :: pandas dataframe read string as date 
Python :: python check if class has function 
Python :: assign multiple variables in python 
Python :: list python virtual environments 
Python :: heroku python version 
Python :: python count empty lines in text file 
Python :: json python 
Python :: How to remove all characters after character in python? 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =