What is My Mistake?


#1

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


#2

What makes you say there is one? It certainly won’t run, but that’s probably got more to do with not having told the forum to not reformat your code as if it were regular text. Anyone comparing your code to instructions would also need a link to the exercise.


#3

because of “Indent” before (if, return, elif …)
your code should look like this:

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

Note that in codecademy.com they are useing two spaces as indent


#4

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