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 trial

Python Functional Python Functional Workhorses Map and Filter Comprehension

please help me with python functional programming

I have no idea how to solve it, but it seems really close to the right answer...

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, temperature for temperature in temperatures if temperature >= 9 and temperature <=32.6)

2 Answers

Bart Bruneel
Bart Bruneel
27,212 Points

Hey,

you will need to repeat the variable temperature in the and-statement so like this:

good_temps=[(...] and temperature <=32.6]

I pass the challenge ! thanks a lot!!

Bart Bruneel
Bart Bruneel
27,212 Points

Hello Pala,

You don't need the map-function in your solution. You can just use the function c_to_f in your list comprehension. Remember that list comprehensions are defined with angle brackets. Part of the solution:

good_temps=[c_to_f(temperature) for temperature in (...)]

Hope this helps.

thank you! but I still stuck at " if the Celsius temperature is between 9 and 32.6."

  good_temps=[c_to_f(temperature) for temperature in temperatures if temperature >=9 and <=32.6]

python can't underdstand what I mean