Transportation code error


#1



I'm stuck on this exercise,

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

And when I save and submit I get the following error message:

Oops, try again. An error was raised for rental_car_cost(1): local variable 'rental_car_cost' referenced before assignment


This is the code I input:

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

Thank you for your help!


#2

Reason of Error ?

rental_car_cost == 40 * days
You've used ==
There, It is an assignment statement.

Hints!!

# Assignment
x = 3

# Comparison 
x = 3
y = 4
x == y

do tell if it solved your problem!
hope it helps . :slight_smile:


#3

Thank you so much, that solved my problem :slight_smile:


#4

You're welcome ! :slight_smile:


#5

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