Taking a Vacation Lesson 3


#1

Hi guys, new to posting so if any adjustments need to be made please let me know.
I am getting an error on Lesson 3 and I am not sure what I am doing incorrectly.
Here is my code:

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 == "222"
elif city == "Los Angeles"
return == "475"

And the error I am getting is : Oops, try again. Did you create a function called plane_ride_cost?

Any feedback would be very helpful, thank you!


#2

Hi

You shouldn't write return == "..", because == will only check if return is "...". Instead, you should write return 475 for example. And it would be better, if you use the numbers as integers, instead of strings, to actually calculate with them, so leave out the "" at the numbers out as well :slightly_smiling:


#3

Wow that cleans up my code up nicely thank you! I am still getting that same error:

Did you create a function called plane_ride_cost?

Which I thought was done by here: def plane_ride_cost(city)

Am I being dumb with this?

I really appreciate your help that makes a lot of sense with the ==!!


#4

Did you try to restart your browser, or reload the page? That sometimes helps too.

If that doesn't work, would you mind, pasting your new code once again so we can take a look again? :smiley:


#5

Just tried that and it's still not working :frowning: Here is the new code

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 222
elif city "Los Angeles"
return 475

Thanks a bunch!


#6

Oops ^^
Didn't see that the : is missing in every line, sorry :frowning:

You should also put : at the end of every if and elif :smiley:

And you're welcome. I'm glad that I could help :smiley:


#7

I did not know that! Learn something new every day!

And I hate to be a bother but same error:
Oops, try again. Did you create a function called plane_ride_cost?

Edit: I also tried closing the browser and it did not help. D:


#8

Hmm... I'm not sure..

Here is my code (I don't like to give my code but rather explain it to you, but here I have no choice left :frowning: )

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
    else:
        return """Please choose from the listed cities:
        -Charlotte
        -Tampa
        -Pittsburgh
        -Los Angeles"""

You could try to compare those two or put it into the editor to pass the test ^^
And you don't bother at all :smiley: Could be a bug or we didn't see a little mistake. Just ask whenever you want and I'll try to help :slightly_smiling:


#9

I appreciate you sharing your code and I think I figured it out based off that.

With mine the plane_ride_ cost(city): is defined but I didn't have it set to have the entered text equal city at all. All I did was add the == after the city and it worked!
Also thanks for not only all your help but the tip on : after if and elif!
You have been a huge help!


#10

You're welcome ^^

And also didn't notice that the == was missing as well :disappointed:

I'm really sorry q.q


#11

Oh don't be you helped me quite a bit and your teaching skills are better than you thought as well! :grinning:


#12

add : after if apartment


#13

I pointed it out, see?


#14

I just had the same issue.

I looked at it again, and they led you into this by leaving the old code there without forcing you to create a new line without the indentation.

Check to see if your new def is indented.

def hotel_cost(nights):
return 140 * nights

(HERE)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
else:
return "No City Found"

Hope that helps.