Taking a vacation 3/7



the code below shows an error on console it says:

File “python”, line 5
if city == “Charlotte”
SyntaxError: invalid syntax

also, another error at the bottom of the editor says: "Did you create a function called plane_ride_cost?"
so i guess the editor can’t read the definition of the function on line 4 for some reason… does anyone have an idea why ? is it the indention causing this error ?

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


yes, here:

  	if city == "Charlotte"
    		return 183
    elif city == "Tampa"

the indent level of if and elif doesn’t match, change if to match the indent level of your elifs


Look at your if/elif statements. You forgot to add a colon : at the end, that’s why you’re getting the error.


by matching indents levels you mean first letter of if and first letter of elif should be at the same line vertically am i right ?


Yes you’re correct i fixed it and it works now, thank you very much


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