+ 1

for loop in python

i have two list: list1 = [1,2] list2 = [3,4] i want output be: 1,3 2,4 i want do this with for loop. what should i do?

4th Dec 2020, 11:03 AM
Parham Shafiei Sabet
Parham Shafiei Sabet - avatar
2 Answers
+ 4
You can use zip function that takes several sequences and returns a sequence of tuples (firstelement from first sequence, second from second, etc) https://code.sololearn.com/cDCrq12KsQaC/?ref=app
4th Dec 2020, 11:09 AM
Volodymyr Chelnokov
Volodymyr Chelnokov - avatar
+ 3
Iterate through first list. At each iteration, print the element from the first list along with the element with the same index from the second.
4th Dec 2020, 11:20 AM
Sonic
Sonic - avatar