Taking a vacation 8. unexpected error


#1

when i run my code, i get an error message reading "Oops, try again. An error was raised for rental_car_cost(1): global name 'cost' is not defined", yet i have no clue why

def hotel_cost(nights):
    return 140 * nights
def plane_ride_cost(city):
    if city == 'Charlotte':
        return 183
    if city == 'Tampa':
        return 220
    if city == 'Pittsburgh':
        return 222
    if 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

#2

Hi @friendlymegalomaniac,

You have ...

    cost == days * 40

That is not an assignment statement, since you are using the == operator instead of the = operator. In its current state, it is a conditional expression, with cost not yet defined.


#3

2 posts were split to a new topic: Taking a Vacation: Error


#4

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