Define Cost? I'm Confused


#1


https://www.codecademy.com/courses/python-beginner-P5YtY/1/3?curriculum_id=4f89dab3d788890003000096#

It's saying this error:
Oops, try again. An error was raised for rental_car_cost(1):
global name 'cost' is not defined

I think it's supposed to use cost without defining it like with "nights" and "days".


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


#2

This is a comparison, not an assignment. Remember to define cost in the first line of the block.

cost = days * 40

#4

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