16/19 - what is wrong here?


#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):
if a>=b:
print list_a
else:
print list_b


#2

You probably do not want to print the whole list just the iterator you are on.

for a, b in zip(list_a, list_b):
    if a > b:
        print a
    elif b > a:
        print b
    elif a == b:
        print 'Equal'

#3

Try this:
list_a = [3, 9, 17, 15, 19]
list_b = [2, 4, 8, 10, 30, 40, 50, 60, 70, 80, 90]
print zip(list_a, list_b)
for a, b in zip(list_a, list_b):
# Add your code here!
if (a > b):
print a
else:
print b


#4

Try this:

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):
    print max(a,b)

#5

This is my code and it worked;
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 a
elif b > a:
print b
else:
print b


#6

this worked for me:

if a > b:
    print a
else:
    print b

#7

I don't understand!!! Someone can explain, please?

Here is the code that I used:

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 a
else:
print b

it gave me:

3
9
17
15
30
None

The instructions said:
Compare each pair of elements and print the larger of the two.

The larger is list b, why it printed the elements on list_a ????

Even with the wrong aswers it allowed me to go ahead....


#8

You did it correctly, the instructions mean compare the numbers in the lists and print which one is bigger. So, 3 > 2, print 3. 9 > 4, print 9 etc. You were not asked to print the longer list.


#10

This was the 1st approach I had...


#11

this is where i was confused too. then i read it again, it made sense