4. Transportation


I keep getting the message "Oops, try again. An error was raised for rental_car_cost(1): global name 'cost' is not defined."

I'm not sure where I've gone wrong- if someone could please explain? Thanks.

def rental_car_cost(days):
    cost == 40 * days
    if days >= 7:
        return cost -50
    elif days >=3:
        return cost -20
        return cost


'==' is a comparison operator.

If you need to save something in an identified(variable),you need to use assignment operator. ( =)


Ok, perfect- it worked! Thank you!


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