4. transportation


#1

Hi,

Could you please help me with my code. Problem probably lay in counnting percentages.

def hotel_cost(nights):
    nights = 140 * nights
    return 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 = days * 40
    if days >= 7:
        cost %= 50
    elif days >= 3:
        cost %= 20
    return cost

error:
Oops, try again. It looks like rental_car_cost returns 0 instead of the correct amount (100) for 3 days.


Taking a Vacation, exercise 4) Transportation, rental_car_cost
#2

% is the modulo operator, why would you use it here?


#5

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