"Getting There"


#1


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


def hotel_cost(nights):
    return 140 * nights
def plane_ride_cost(city):
    return "Charlotte":  183
    return "Tampa":  220
    return "Pittsburgh":  222


#2
 After I run my code, it doesn't run correctly.  Please advise.

Thanks!

Ian Michael Jones


#3

You should use the if and else if statement
fo the first on it wil be a if statement it will be something like that

def plane_ride_cost(city):
    if city == "Charlotte": # if the city is "Charlotte"
        return 183 # return 183
    ...

#4

you are just trying to straight up return all of those values, even though it makes sense, you can't do it like this.

try and set it up like this:

def hotel_cost(nights):
    return 140 * nights
    
def plane_ride_cost(city):
    if # this city:
        return # this value
    elif # this city:
        return # this value
    elif # this city:
        return # this value
    elif # this city:
        return # this value

#5
 After trying your suggestion, my code ran correctly.  Thanks for all of your help nickgrimes50! I really do appreciate it!

Sincerely,

Ian Michael Jones


#7

I did that but it tells me something else

def plane_ride_cost(city):

    if city == Charlotte:
        return 183
    elif city == Tampa:
        return 220
    elif city == Pittsburgh:
        return 222
    elif city == los Angeles:
        return 475

#8

what do you mean it tells you something else?


#9

very unlikely @keyboardeot is going to read this topic after 10 months, he is also hijacking the topic.

well, Charlotte is a undefined variable in his code, it should be a string.


#10

you’re probably right lol, I came across codecademy again after this long hiatus and I saw in my notifications. 1 yr 10 moths is a little delayed :joy:

and that makes sense I remember now that we didn’t have any assignments in these lessons.


#11

that is why "Charlotte" should be a string, otherwise you have a undefined variable. But its very unlikely any one comes back to a topic after 10 months, if you have other unanswered notifications please leave it that way :wink: