Can't seem to figure out the problem with what I'm doing. Help please!?


Taking a Vacation.pdf (67.7 KB)

I'm stuck, and I believe I have the indentations correct, but the message I keep getting is:

Oops, try again. trip_cost('Los Angeles', 5) raised an error: cannot concatenate 'str' and 'int' objects


Can you post your code?


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

def trip_cost(city,days):
return city+days
print trip_cost('Tampa',1)

*I have indentations in play, they are just not translating when I copy and paste. PDF attached in original post


Read the instructions again, please. Sorry for a late answer by the way. Instructions, part two:

Like the example above, have your function return the sum of calling 
the rental_car_cost(days), hotel_cost(days), and plane_ride_cost(city) functions.

After this, look at the example

def add(a, b):
    return double(a) + triple(b)

You should do a variation about this. The only difference is that your parameters are nights and days and you return result of three functions, plane_ride_cost, rental_car_cost and hotel_cost.

You will found everything else from the instructions.


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