+ 3

Loops in python

Help me pls List1 =["Sunday", "Monday", "Tuesday"] List2 =["first", "second", "third"] How to make output like this : Sunday first Monday second Tuesday third I tried to make double for but the output like this: Sunday first Sunday second Sunday third Monday first Monday second Monday third Tuesday first Tuesday second Tuesday third This is the code: https://code.sololearn.com/cA13fULaN9rh/?ref=app

10th Nov 2021, 4:23 PM
Gibran Daffa
Gibran Daffa - avatar
4 Answers
+ 4
How about this? for i in range(len(list1)): print(list1[i], list2[i])
10th Nov 2021, 4:27 PM
Lisa
Lisa - avatar
+ 6
Gibran Daffa , here are 2 other possible ways to do it: List1 =["Sunday", "Monday", "Tuesday"] List2 =["first", "second", "third"] # using enumerate() for ind, _ in enumerate(List1): print(List1[ind], List2[ind]) print() # using zip() for tup1 in zip(List1, List2): print(*tup1)
10th Nov 2021, 6:08 PM
Lothar
Lothar - avatar
+ 3
Lisa oh thanks, im understand now
10th Nov 2021, 4:38 PM
Gibran Daffa
Gibran Daffa - avatar
+ 3
Lothar thank you bro, But I haven't learned enumerate() and zip(), i will learn it later, but its still useful
10th Nov 2021, 11:26 PM
Gibran Daffa
Gibran Daffa - avatar