Taking a Vacation 4.Transportation


#1

Hey guys,

Can someone please tell me what do i do wrong here ?


#2

Not a problem anymore. I discovered that i didn't "returned cost" after if statement.


#3

Glad you found the issue on your own. You could also instead of having the else statement at the end just return cost like this

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

This saves you having to return cost 3 times and only modifies cost in the if and elif statements


#4

Oh thanks man :smile: Really helps me in the future since everything i am learning now will " stick " in my brain