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

I can't tell if your indentations are correct (you can put three accent marks, like this ( ` ) , before and after your code to format it).

But I noticed two things that you should look at:

  1. 'Spending money' is spelled 'sending money' in some places, and
  2. 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)

(Oh, don't forget the quotes around Los Angeles).
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 can enter two real arguments(actual info):

print give_info("John", "twenty")

You are close to a solution. Good luck!


#3

..................
thanks
..................


#4

''' 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, spending_money) :
return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days) + spending_money
print trip_cost("Los Angeles",5,600) '''

now here is the new code what is wrong now?


#5

print trip_cost("Los Angeles",5,600) try it and dont press tab before print


#6

thanks...........................