'Charlotte is not defined'- an error message I can't fix


#1



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


Traceback (most recent call last):
File "python", line 8, in
File "", line 1, in
NameError: name 'Charlotte' is not defined


I'm not entirely sure why Charlotte (or any other city) needs to be defined. Surely if it is something I want the input to equal it wouldn't. If this is wrong, why and what should I define them as. My code works fine up until my if statement.


print ("Welcome to the holiday planner. Here we take all the imformation we need in order to plan the cost of your holiday and add it up so you don't have to. Happy Holidays!")
print ("*****************************************************")
hotel_cost=input("How much does your hotel cost for one night?")
nights=input("How many nights will you be staying for?")
def hotel_cost (nights, hotel_cost):
    return hotel_cost*nights
print ("Your opitions for location are Charlotte, Tampa, Pittsberg or Los Angeles")
city=input("Where are you going")
def plane_ride_cost(city):
    if city=="Charlotte":
        return 183.00
    elif city=="Tampa":
        return 220.00
    elif city=="Pittsburgh":
        return 222.00
    elif city=="Los Angeles":
        return 475.00
    else:
        print ("invalid answer, you will have to start the program again, to do so please reload the site.")


#2

It doesn't need to be defined, the problem is that you're trying to read from a variable by that name.

Use raw_input, input() is equivalent to eval(raw_input())) which is quite inappropriate for what you're doing


#3

input not eval string if int and float.

for eval string use raw_input.

for eval numbers use input.

Is a suggestion of what I have practiced
sorry for my english


#4

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