This community-built FAQ covers the “Divide With Zip” exercise from the lesson “List Comprehension”.
Paths and Courses
This exercise can be found in the following Codecademy content: Analyze data with Python
FAQs on the exercise Divide 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.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Hi, can someone show an example of what they mean by Divide With Zip?
I don’t understand how to use math functions with the Zip command. Thanks.
Here’s the link to the question:
Divide and zip are separate concepts
divide is a function taking in two arguments and returning one value
if you have two lists, you can iterate through them in sync
for a, b in zip(list_of_as, list_of_bs):
print(a, b)
map also already has this pairing/grouping behaviour built in:
from operator import div
a = [1.0, 2.0, 3.0]
b = [4.0, 5.0, 6.0]
map(div, a, b) # 0.25 0.4 0.5
Hello, there are some issues with accepting correct answers. Already reported a bug.
The code:
a = [1.0, 2.0, 3.0]
b = [4.0, 5.0, 6.0]
quotients = [b / a for (a, b) in zip(a, b)]
print(quotients)
The program doesn’t accept it, but outputs the correct “print()” statement.
Also shows: “zip argument #1 must support iteration”.
And, at the previous exercise-challenge with summation, everything was ok with this style of coding.