16. Multiple lists


#1



https://www.codecademy.com/en/courses/python-beginner-en-cxMGf/2/3?curriculum_id=4f89dab3d788890003000096


It says Oops, try again. "2" was printed instead of "3".


list_a = [3, 1, 17, 15, 30]
list_b = [2, 4, 8, 99, 30, 40, 50, 60, 70, 80, 90]

for a, b in zip(list_a, list_b):
    if a > b:
        print b, a
    elif a < b:
        print a, b
    else:
        print "Numbers are the same"


#2

If a > b you want to print a, nothing more.

And if numbers are the same you should print out the value to the console. So when a = 30 and b = 30 you have to print to the console 30.


#3

Yes you are right Mr factoradic. this is how I wrote mine:

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 worked perfectly just like that.


#4

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,
print # print is required to create space between last number and characteristic inherent none


#5

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


#6

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