I am having the below two lists:
first= (1,2,3,4,5,6)
last=(6,5,4,3,2,1)
I want to compare the corresponding values only. I have written the below code, but it is comparing the elements 36 times!
for x in first:
for y in last:
if x>y:
print("first is greater then L2",y)
elif x==y:
print("equal")
else:
print("first is less then L2",y)
irst= (1,2,3,4,5,6)
last=(6,5,4,3,2,1)
for x in first:
for y in last:
if x>y:
print("first is greater then L2",y)
elif x==y:
print("equal")
else:
print("first is less then L2",y)
output:
L1 is less then L2 6
L1 is less then L2 5
L1 is less then L2 4
L1 is less then L2 3
L1 is less then L2 2
go dada
L1 is less then L2 6
L1 is less then L2 5
L1 is less then L2 4
L1 is less then L2 3
go dada
L1 is greater then L2 1
L1 is less then L2 6
L1 is less then L2 5
L1 is less then L2 4
go dada
L1 is greater then L2 2
L1 is greater then L2 1
L1 is less then L2 6
L1 is less then L2 5
go dada
L1 is greater then L2 3
L1 is greater then L2 2
L1 is greater then L2 1
L1 is less then L2 6
go dada
L1 is greater then L2 4
L1 is greater then L2 3
L1 is greater then L2 2
L1 is greater then L2 1
go dada
L1 is greater then L2 5
L1 is greater then L2 4
L1 is greater then L2 3
L1 is greater then L2 2
L1 is greater then L2 1
y
I just need to compare the corresponding elements only. There would only be 6 outputs, not 36!