Need help to 'pull it together'


#1

This is my code:-

def hotel_cost(nights):
    return nights * 140

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

def trip_cost(days, city):
    return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days)

print trip_cost(12, "Tampa")

But this is what it provides as feedback:-
Oops, try again.
trip_cost('Tampa', 8) raised an error: cannot concatenate 'str' and 'NoneType' objects

Please help.


#2

#Your function name should be trip_cost and not tripcost
def trip_cost(city, days):
#This return statement cannot execute until all yor functions have the correct name.
    return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days)

def rentalcar_cost(days):
should be,
def rental_car_cost(days):

def planeride_cost(city):

shoud be,

def plane_ride_cost(city):

def hotelcost(nights):

shoud be,

def hotel_cost(nights):


#3

tried that - I still get the same results - not sure whats going on, but in the preview window - the code works fine


#5

Giving him your code does not solve the error but also robs him of the opportunity to learn and understand what he did wrong. Don't help him pass, help him learn. :grin:


#6

Sorry @bandit will surely remember this next time when answering..

Ronit Gaikwad


#7

Sorry guys - but Im still missing something.


#8

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