It is working but not


Hi, whenever i type a number for the number of day you rent the car it is showing me the right answer but it tells me that error

It looks like rental_car_cost returns 40 instead of the correct amount (80) for 2 days.

The answer is right when i type 0 days it cost 0 , when i type 5 it cost 180 and when i type 7 it cost 230
but i can't submite and continue

any idea why pls?

def hotel_cost(nights):
    return 140 * nights
print ("Choose a destination below")
x = raw_input("Charlotte, " "Tampa, "  "Pittsburgh or "  "Los Angeles")
def plane_ride_cost(x):
    if x == "Charlotte":
        return 183
    elif x == "Tampa":
        return 220
    elif x == "Pittsburgh":
        return 222
    elif x == "Los Angeles":
        return 475
        return "Not valid destination"
print plane_ride_cost(x)

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

print rental_car_cost(days)

print plane_ride_cost(x) + rental_car_cost(days)


Start by removing all the code that is not asked for in the exercise. Once you pass a module, then is the time to experiment and embellish, but not until then. We get best results when we do not stray away from the instructions. Use only what is expected.

Not asked for, and it contains errors.

Also not asked for.

The expected parameter is city.

x is not defined.

Also not expected.

days2 is defined outside of the function, and cannot be seen inside. Use days only. Calculate the total cost inside the function.


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