Need Help


#1

Here is the screenshot of my error

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
def rental_car_cost(days):
rental_car_cost = days*40
if days >=7:
rental_car_cost = rental_car_cost - 50
elif days >=3:
rental_car_cost = rental_car_cost - 20
return rental_car_cost
def trip_cost(city,days):
return rental_car_cost(days)+hotel_cost(days)+plane_ride_cost(days)

Unable to pinpoint the source of error

EDIT: I was able to fix the problem after resetting the code


#2

@jkagoo,

Python uses the indentation as an code-block indicator....
In the rental_car_cost() method you want to express

  • the multiplication of days times standard cost
    rental_car_cost = days * 40
  • in an IF ELIF statement structure you apply a discount to the rental_car_cost
  • you want to return the rental_car_cost Value

Thus

def rental_car_cost(days):
    #normally 4 space indent to start FUNCTION-BODY
    # default rental_car_cost
    rental_car_cost = days*40
    # apply eventual discount
    if days >=7:
        # the IF code-block
       rental_car_cost = rental_car_cost - 50
    elif days >=3:
        # ELIF code-block
        rental_car_cost = rental_car_cost - 20
    # IF ELIF statement structure is ended
    # RETURN rental_car_cost-VALUE
    return rental_car_cost

#empty line, and start over at 1st char-position