Hotel_cost(0) returned None instead of correct value 0


taking a vacation, pulling it all together

oops, try again. hotel_cost(0) returned None instead of correct value 0

when working up to this point, the code for hotel_cost worked and now it's not. doesn't make any sense.
i have even tried not to have the sum = line, just the return "plane..., hotel..., car...'

getting frustrated

def hotel_cost(nights):
    if nights > 0:
        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
        return "You don't want to go there."
def rental_car_cost(days):
    if days >= 7:
        return days * 40 - 50
    elif 3 <= days < 7:
        return days * 40 - 20
        return days * 40
def trip_cost(city, days):
    sum = plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days)
    return sum


this line is a problem:

elif 3 <= days < 7:

not sure what zou are doing here. If you want to do multiply comparisons, you should use the and or or operator. but you don't have to, you could checks if the days are more then 3 (currently, it checks if it is less then 3 days) and then return the right number with 20 discount


if you look at that again it says-

'3' is 'less than or equal to' the amount of 'days' that is 'less than 7'
unless my understanding of logic is that far off

i can understand the and,
elif days >= 3 and days < 7
True and True, which is what the answer needs for the proper discount
yes that makes sense
but not an or
elif days >= 3 or days < 7
this could then give me a True/False or False/True, maybe then giving someone the wrong or additional discount

yet the error that i'm getting has nothing to do with the amount of days that i'm renting a car.
it has to do with the hotel cost.


you should use the and keyword, but you seem to understand that logic

uhm... zero isn't greater then 0, so nothing gets returned


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