Pulling it together


#1

I am so stuck, and have tried a number of different arrangements and codes, can somebody help please?

My error at this point is:
Oops, try again. trip_cost('Pittsburgh', 3, 0) raised an error: unsupported operand type(s) for +: 'int' and 'NoneType'

def hotel_cost(days):
    return 140*days

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
    else:
        return "Unknown"

def rental_car_cost(days):

    if days>=7:
        return 40*days-50
    elif days>=3:
        return 40*days-20
    else: 
        return 40*days

def spending_money(days):
    money = 50*days
    
def trip_cost(city, days, money):
    trip_cost = plane_ride_cost(city) + (days) + rental_car_cost(days) +spending_money (money)

#2

This does not match up with the instructions. Are you making stuff up to experiment?


#3

The extra bit with spending _money def is a last ditch attempt at trying to get it to work, and it was the most complete version of code I have.
Previous to putting that in I was getting errors from the towns not working, days not being defined, errors because it couldn't concatenate an int and string....
I've worked pretty much each suggestion in the discussion but haven't been able to find the correct method, obviously I'm missing something really basic in my code/method but I can't find it.
The term experiment implies some degree of skill or ability .... so no, I'm not experimenting! I only thought it was getting errors due to that not being specifically defined....


#5


Yep, overthinking it again!


#6

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