Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialosman homek
254 Pointsfunctional python map and filter comprehension quiz solution??
according to me, my codes are correct. but i give an "use list comprehension" error. i didnt understand?
thanks
temperatures = [
37,
0,
25,
100,
13.2,
29.9,
18.6,
32.8
]
def c_to_f(temp):
"""Returns Celsius temperature as Fahrenheit"""
return temp * (9/5) + 32
good_temps = map(c_to_f,[tempval for tempval in temperatures if tempval > 9 and tempval < 32.6])
3 Answers
akak
29,446 PointsThere is another way of doing the same thing that map is doing and it's called list comprehension. Kenneth explained it a bit in that course but for more detailed explanation you should watch this http://teamtreehouse.com/library/python-comprehensions.
It should look like this :
good_temps = [c_to_f(temp) for temp in temperatures if temp > 9 and temp < 32.6]
Kenneth Love
Treehouse Guest TeacherYeah, you need to use only a list comprehension, no calls to map()
at all, in this challenge.
osman homek
254 Pointshi akak,
thanks for answer..