FAQ: Learn Python: Loops - More List Comprehensions


#1

This community-built FAQ covers the “More List Comprehensions” exercise from the lesson “Learn Python: Loops”.

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

Computer Science
Data Science

FAQs on the exercise More List Comprehensions

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

Ask or answer a question about this exercise by clicking reply (reply) below!

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

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

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!


#2

Hi all,

So I wrote the following list comprehension to convert the items in celsius to fahrenheit. The conversion worked fine but the new list prints in the console four times. Why is this and how do I fix it please!

celsius = [0, 10, 15, 32, -5, 27, 3]
fahrenheit = [temp * 9/5 + 32 for temp in celsius]

print(fahrenheit)


#3

Can you show us a screenshot of both your code and the result?

All I got from your code is the list,

[32.0, 50.0, 59.0, 89.6, 23.0, 80.6, 37.4]

#4

I’ve just run it again and it now only prints once. I was having intermittent connection issues with the sight earlier so I imagine it’s something to do with that.

Thanks anyway!