+ 2
using two variables in for loop?
How can we use two variables simultaneously in for loop? for x, y in data1, data2: print(x, y)
2 Answers
+ 3
You must do nested loop, or eventually if both structures are list with same number of items ( or dict sharing same properties ^^ ), with a loop on the shared indexes ( or keys )...
Provide much of your code case context if you want more accurate answer ;)
0
for x in data1:
for y in data2:
print(x,y)
or if their lengths are same
for i in range(0,len(data1)):
print(data1[i],data2[i])