FAQ: List Comprehension - Greater Than With Zip

This community-built FAQ covers the “Greater Than With Zip” exercise from the lesson “List Comprehension”.

Paths and Courses
This exercise can be found in the following Codecademy content:

FAQs on the exercise Greater Than With Zip

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

So my solution to this exercise was:

a = [30, 42, 10]
b = [15, 16, 17]

values = zip(a,b)

greater_than = [a > b for (a,b) in values]

print(greater_than)

Which seems to work.

But I am getting a message from the course: ’ Zip argument #1 must support iteration’

Anyone know what’s wrong with the code? I’m stuck

I believe the issue you are having is that variables a and b are already defined, and you use them again in your list comprehension. You can take what you have and modify a>b for (a,b) to a1>b1 for (a1,b1) and your solution will work.

Also, consider using zip in the list comprehension, instead of creating values.

greater_than = a1>b1 for (a1,b1) in zip(a,b)

Cheers,

-N

1 Like