Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Simple Python Question w/ List Comprehension without wasting too much if your time.
The question is published on by Tutorial Guruji team.
The question is published on by Tutorial Guruji team.
Why is this wrong? I had ran it before and it worked but for some reason now it isn’t running. It’s very easy and I’m a beginner so I’m struggling to figure it out.
def checkTemp(x): if x == 0: return 0 elif x > 32: return 'above' elif x == 32: return 'freezing' elif x < 32: return 'below' def aboveBelowFreeze(tempList): ''' Given a list of temperatures, return a list of strings that say 'above', 'below', or 'freezing', depending on whether the temperature was above 32, below 32, or equal to 32. Create a helper function if you need it. ''' return ([checkTemp(x) for x in tempList])
Answer
It should be working fine as long as you are calling the aboveBelowFreeze function with a list input. Having something like this outside the functions with no indent:
print(aboveBelowFreeze([40,2]))
We are here to answer your question about Simple Python Question w/ List Comprehension - If you find the proper solution, please don't forgot to share this with your team members.