Taking a Vacation, exercise 4) Transportation, rental_car_cost


#1



Please help me with my code!!

Python Programming: Taking A Vacation, rental_car_cost, 4) Transportation


Apparently, it says that my 'rental_car_cost' returns 120 instead of the correct amount (100) for 3 days.


I have done everything it says and I expect to work fine but it doesn't seem so. I have even looked at the example for this particular exercise for reference.


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):
    price = 40 * days
    if days >= 7:
        price - 50
    elif days >= 3:
        price - 20
    return price


#2

this:

price - 50

will not update price, look:

i = 10
print i # 10
print i -5 # 5
print i # 10
i = i - 5
print i # 5

#3

Ok thanks a lot man!! :slight_smile:


#4

A post was split to a new topic: 4. transportation


#5

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