Why does this not work? Python Loops 16/19


#1

list_a = [3, 9, 17, 15, 19]
list_b = [2, 4, 8, 10, 30, 40, 50, 60, 70, 80, 90]

for a, b in zip(list_a, list_b):
# Add your code here!
if list_a > list_b:
print list_a
break
else:
print list_b
break

this does what the instructions tells it to, just in an alternate way. It comes up with the error:
Oops, try again. "2" was printed instead of "3".

correct me if i'm wrong but this was not the error I was expecting. I was however expecting an error in the way I wrote my code, such as 'you did not use elements!' or something.


#2

What you posted won't run at all, perhaps you're using something a little different?

You've got a loop that assigns values to variables a and b, but you aren't using those variables at all, isn't that a little odd?

Without having read the instructions, I assume that you're meant to print out one element at a time, but the print statements that you have are printing out lists, isn't that contrary to what your code is supposed to do?


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.