“Python iterate over tuple of lists” Kode Jawaban

Loop melalui daftar tupel 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
wolf-like_hunter

mengulangi daftar tupel

#listOfTuples =  [("hello", 1)]
for k, v in listOfTuples:
	print(k , v)
#output : hello 1
amahi2001

Python iterate over tuple of lists

tuple_list = ([1,2,3], ['label1', 'label2', 'label3'])
for val, label in zip(*tuple_list):
     print(val, label)
Energetic Eland

Jawaban yang mirip dengan “Python iterate over tuple of lists”

Pertanyaan yang mirip dengan “Python iterate over tuple of lists”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya