16.Multiple Lists Help me out of this..?!

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/python-beginner-en-cxMGf/2/3?curriculum_id=4f89dab3d788890003000096#
<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

```python

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

<do not remove the three backticks above>

a and b hold the lists, you can just compare them. Not sure what a(list_a) is suppose to be

To compare each pair of elements and print the larger of the two, you could do the below although your code should work fine:

print max(a, b)

3 Likes

I agree with bayoishola20 . The less code is better, but what if the values at the index position were the same? I believe it would be best to use the other method. For example…

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 a
    elif a < b:
        print b
    else:
        print "Numbers are the same"

Also, list_b has more index items than list_a. Is there a way to print these in the same code?

4 Likes

That’s a good point about the possibility of equal values, in which case, neither is “larger”, strictly speaking. So combining the suggestions of the two solutions above, you could address this a little more succinctly like this:

for a, b in zip(list_a, list_b):
    if a == b:
        print "Values are equal, so neither is larger"
    else:
        print max(a,b)

1 Like

Pretty unhelpful answer.

no, why? a and b holds the items in the lists in turn, and then you can just compare a and b. Yes, there is some thinking left to do, since you have to remove the function calls.

Saying an answer is unhelpful is also not very helpful, at least then tell why the answer is unhelpful

1 Like

Hi @jaydacoder, really good point there.

Awesome @designcoder87342

Thank you! :slight_smile:

Benefits of a community.

1 Like

Why does this run 4 times?

1 Like

You simply repeated the question. “…you can just compare them.” Someone asks a teacher “How do I compare lists?” and the teacher says, “You can just do it.” Good teacher or bad teacher?

maybe not my best answer, but the second explanation is better_emphasized text_