Transportation


#1

def hotel_cost(nights):
    hotel_cost = 140 * 2
    return hotel_cost
    
def plane_ride_cost(city):
    if city == "Charlotte":
        return 183
    if city == "Tampa":
        return 220
    if city == "Pittsburgh":
        return 222
    if city == "Los Angeles":
        return 475


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

can any one tell me what's gone wrong in above program.


#2

the variable which contains the cost has the same name as the function? This sounds like a bad idea


#3

I am unable to find mistake, could you please show me where i did wrong.

when i click on save&submit it shows me as below
File "python", line 19
return rental_car_cost -= 50
^
SyntaxError: invalid syntax


#4

File "python", line 19
return rental_car_cost -= 50
^
SyntaxError: invalid syntax

what was wrong in it


#5

well first of all, i would rename the variable which hold the total cost.

second, you can't update a variable and return it at the same line. either update the variable and return on the line below, or simply return cost - 50 (or 20)


#6

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