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 trialJohn Story
7,885 Pointsfunctional python c_to_f not working
I am stuck on the challenge task using list comprehension in place of filter and reduce, i have the code below.
which works if i break it out into the repl, but it's not passing. Does anyone know why?
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 = [ c_to_f(t) for t in temperatures if t > 9 and t < 32.6 ]
2 Answers
Max Hirsh
16,773 PointsIt looks like your variable good_temps is indented and probably interpreted as part of def c_to_f. Does it work when you unindent it?
Keith Doyle
25,973 Pointssame thing happened to me. didn't even check and it was killing me that my code wouldn't pass.
Thanks!