# "Pull it Together"

#1

``````def hotel_cost(nights):
return 140 * nights
def plane_ride_cost(city):
if city == "Charlotte": # if the city is "Charlotte"
return 183 # return 183
if city == "Tampa": # if the city is "Tampa"
return 220 # return 220
if city == "Pittsburgh": # if the city is "Pittsburgh"
return 222 # return 222
if city == "Los Angeles": # if the city is "Los Angeles"
return 475 # return 475
def rental_car_cost(days):
rent = 40 * days
if days >= 7:
return rent - 50
elif days >= 3:
return rent - 20
return rent
def trip_cost(city, days):
return sum``````

#2
`` I am stuck when it comes to the correct code for this coding exercise.  Please advise.``

Thanks!

Ian Michael Jones

#3

What seems to be the problem? What prevents you from moving on? What information do you need to figure it out?

Better to ask questions than to just state that you are stuck!

#4
`` I am stuck on deciding the correct code for line 20 of my code.  Please advise.``

Thanks!

Ian Michael Jones

#5

`trip_cost` is supposed to call the other functions and add their results.

#6
`` Please tell me if I am on the right track.  Thanks for all of your help in advance.  Here is my code:``

def hotel_cost(nights):
return 140 * nights
def plane_ride_cost(city):
if city == "Charlotte": # if the city is "Charlotte"
return 183 # return 183
if city == "Tampa": # if the city is "Tampa"
return 220 # return 220
if city == "Pittsburgh": # if the city is "Pittsburgh"
return 222 # return 222
if city == "Los Angeles": # if the city is "Los Angeles"
return 475 # return 475
def rental_car_cost(days):
rent = 40 * days
if days >= 7:
return rent - 50
elif days >= 3:
return rent - 20
return rent
def trip_cost(city, days):
sum = rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)
return trip_cost

`` Here is a hyperlink to the exercise that I am stuck on.: https://www.codecademy.com/courses/python-beginner-P5YtY/1/4?curriculum_id=4f89dab3d788890003000096.``

Sincerely,

Ian Michael Jones

#7

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
else:
return 475

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

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

this worked for me but i was getting an error on the last part def trip_cost(days, city): but when I changed the order city first it worked def trip_cost(city, days):

#8
`` I still get an error after I run my code.  Here is my code:``

def hotel_cost(nights):
return 140 * nights
def plane_ride_cost(city):
if city == "Charlotte": # if the city is "Charlotte"
return 183 # return 183
if city == "Tampa": # if the city is "Tampa"
return 220 # return 220
if city == "Pittsburgh": # if the city is "Pittsburgh"
return 222 # return 222
if city == "Los Angeles": # if the city is "Los Angeles"
return 475 # return 475
def rental_car_cost(days):
rent = 40 * days
if days >= 7:
return rent - 50
elif days >= 3:
return rent - 20
return rent
def trip_cost(city, days):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

`` I also get an error that states, "File "python", line 7 SyntaxError: 'return' outside function." Please advise.``

#9

Could you try to change the if on rows 6, 8 and 10 to elif and try again?

#10
`````` After changing my if statements on rows 6, 8, and 10 to elif statements and then try again, I get an error that states, "File ;python', line 6
elif city == 'Tampa': # if the city is 'Tampa'
^``````

Thanks!

Ian Michael Jones

#11

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

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

#12

def hotel_cost(nights):
return 140 * nights

def plane_ride_cost(city):
if city == "Charlotte":
return 183
if city == "Tampa":
return 220
if city == "Pittsburgh":
return 222
if city == "Los Angeles":
return 475

def rental_car_cost(days):
cost = 40 * days
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost
def trip_cost(days, city):
sum = hotel_cost(days) + rental_car_cost(days) + plane_ride_cost(city)
return trip_cost

`` After plugging this code in, I get a syntactical error.  Please advise.``

Sincerely,

Ian Michael Jones