Multiple Lists-"2 was printed instead of 3"


#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 a > b:
print "Bigger in pair: %s"%(a)
else:
print "Bigger in pair: %s"%(b)
What is my mistake?


#2

I have run code without "Bigger in pair: %s" print statement....code ran well, but with this print phrase, i have getting this message "2 was printed instead of 3". Why?


#3

Well, code looks ok, I am guessing indetation is the problem.
Paste your code again, highlight it and press Ctrl + Shift + C


#6
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 a > b:
        print "Bigger in pair: %s"%(a)
    else:
        print "Bigger in pair: %s"%(b)

#7

Indents are also ok.

Change your print statements into just print a print b

if a > b:
        print a
    else:
        print b

I don't know why your version doesn't work. Unfortunatelly sometimes adding something more than necessary minimum causes problems


#8

Yeah...I think so....
So i should execute it naturally without adding other stuff.
Thanks for replying....


#9

Interpreting instructions literally is usually the way to go. Details matter too much in programming for anything else to work. So if you think it works, but some computer does not - then usually you need to follow the instructions more literally. Hopefully the frustrating experience with this helps a bit in the future when you encounter similar problems.


#10

Your code is fine in just try changing %s to %d as we are dealing with numerals here and %s is basically a format specifier for strings and might as well throw an error in accordance to Python 3.3