Getting there


#1



https://www.codecademy.com/courses/python-beginner-P5YtY/1/2?curriculum_id=4f89dab3d788890003000096


i am getting the error inspite of creating a function

Oops, try again. Did you create a function called plane_ride_cost?

n


def hotel_cost(nights) :
    return 140*nights

def plane_ride_cost(city):   
    
    if city==Charlotte:
        return 183
    elif city==Tampa:
        return 220
    elif city==Pittsburgh:
        return 475
    else :
        return 0


#2

Ok so first off, all your cities need to be in quotes. This particular function accepts a string as an argument so that is why they need to be in quotes. Secondly, I believe you are missing Los Angeles...

"Pittsburgh": 222
"Los Angeles": 475

#3

thank you just did that.. and it worked

but .
now my question is why does the system again asks me to define function when i have already defined it.
thanks again..


#4

Can you explain a little bit more? I am not quite sure what your getting at.... Like are you asking why you have to include something in your code or you getting something on your module screen once the code passes?


#5

the error i got then ( before you helped me ) was .
it asked ""did you define the function"" when i had already defined it..( on the module screen)
but i just did what you advised and it worked..
thank you..


#6

When you ran your code the function is taking in string arguments. The function is defined by those arguments in the if else and elif statements underneath it. If it can't read the arguments because they are not in strings they are undefined thus making the function undefined. I think that is the simplest way I can think to put it haha. Might be to simple but I believe fully correct.


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.