6-7 Codeacademy altering raw_input data


It works, I believe but my issue is this... The raw_input value I enter is being changed for some reason. It works fine but since adding the Spending_money, it's randomly imputing it's own raw_inputs which is cancelling the ones I have entered.

city = raw_input("Type the city you're visiting."
days = float(raw_input("Amount of days you're staying?"))
def hotel_cost(nights):
    if nights:
        return 140 * nights
        return 0
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
        return "Please enter a valid location/amount of nights"
def rental_car_cost(days):
    rent = 40 * days
    if days >= 7:
        return rent - 50
    elif days >= 3:
        return rent - 20
        return rent
def trip_cost(city, days, spending_money):
    if spendingmoney(spending_money):
        return spending_money
    return rental_car_cost(days) + plane_ride_cost(city) + hotel_cost(days) + spendingmoney(spending_money)
print trip_cost(city, days, spending_money)

Console message:
Type the city you're visiting. Tampa
Amount of days you're staying? 4
function spending_money at 0x7f6bfac96410

Error code from assignment
Oops, try again. trip_cost('Tampa', 7, 70) returned 70 instead of the correct value 1500


Hey there. Looks like you have the same problem with the spending_money function again -- you're printing it instead of calling it.

Further, the new function isn't included in the code -- I can't see what might be modifying the value.

As for it returning 70, that makes sense.

Whatever spendingmoney(var) is returning is True, therefore the method is returning spending_money. See this section in trip_cost(): if spendingmoney(spending_money): return spending_money

It's returning.


Don't know why but it required me to put in a value for Spending_money even though it didn't specify it in the instructions. although since add a raw_input for it, it works correctly.