# Pull it together

#1

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 0

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

def trip_cost(city, days):
return (hotel_cost(days) + plan_ride_cost(city) + rental_car_cost(days))
def hotel_cost(nights):
cost_hotel= nights*140
return cost_hotel

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):
if days >= 7:
return (40*days) - 5
elif days >= 3:
return (40*days) - 20``````

else:
return 40*days

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

I have this code but it doesn't work, does anybody know why???

#2

File "python", line 7
elif city == "Tampa":
^
SyntaxError: invalid syntax

I also have this error that I don't know how to deal with

#3

in "rental_car_cost" should be:

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

Because it must be more than 3 but less than 7
I hope it works

#4

it didnt work not for me anyway

#7

You don't have to set an upper limit for the elif, so remove the continuation
of it.

``````elif days >= 3:
return cost - 20``````

Another problem that you have is that you don't have else- statement. If length of days doesn't meet the requirements it should just return cost.

``````else:
return cost``````

#8

I got it to work for me

#9

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