+ 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
4 Respuestas
+ 4
How about this?
for i in range(len(list1)):
print(list1[i], list2[i])
+ 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)
+ 3
Lisa oh thanks, im understand now
+ 3
Lothar thank you bro, But I haven't learned enumerate() and zip(), i will learn it later, but its still useful