What's wrong witht his code?


#1


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

IndentationError: unindent does not match any outer indentation level


def rental_car_cost(days):
     cost = 40 * days
     if days >= 7:
         return cost - 50
     elif days >= 3:
        return cost - 20
     else return cost


#2

you forgot a colon (:) after else.


#3

i put in a colon but the same error message reappeared.


#4

def rental_car_cost(days):
     cost = 40 * days
     if days >= 7:
         return cost - 50
     elif days >= 3:
        return cost - 20
     else:
        return cost

IndentationError: unindent does not match any outer indentation level


#5

is this your full code? if not, please post your full code with markup:

otherwise try refreshing the page/switching browser, the code you posted above is fine


#6

the error is talking about indentation. How do i rectify that?

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   
 def rental_car_cost(days):
     cost = 40 * days
     if days >= 7:
         return cost - 50
     elif days >= 3:
        return cost - 20
     else:
        return cost`

IndentationError: unindent does not match any outer indentation level


#7

this line:

 def rental_car_cost(days):

has indention (one space) for no reason, causing it not to match with any other indent, causing the error


#8

Thanks! That solved it :slight_smile:


#9