Plan your trip


#1

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 hotel_cost(nights):
return 140*nights

def rental_car_cost(days):
cost = 40 * days
if days>=7 :
return cost - 50
elif days>=3 :
return cost - 20
return cost

def trip_cost(city,days,sending_money) :
return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days) + sending_money
print trip_cost=plane_ride_cost(Los Angeles) + hotel_cost(5) + rental_car_cost(days) + spending_money(600)



What is wrong with my code?!


#2

Hi, I just answered your question where you posted it before. I've cut and pasted the answer here as well.

I noticed two things that you should look at:

'Spending money' is spelled 'sending money' in some places, and you made a function trip_cost that takes three arguments (city, days, s(p)ending money).
It should look like this:

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

Now when you want to call and print this function, you want to write it like this:

print trip_cost("Los Angeles", 5, 500)

Don't forget the quotes around Los Angeles. Of course you could use any city, any number of days, and any amount of spending money in place of these figures, for example:

print trip_cost("Pittsburgh", 6, 200)

Functions can be tough to get used to. If I have a function like this:

def give_info(name, age):
    return "Hi " + name + " you're " + age + " years old!"

When I call it (that is, when I want to use it), I enter two real arguments(actual info):

print give_info("John", "twenty")

You are close to a solution. Good luck!