How to correct the output of a function?


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/taking-a-vacation/exercises/pull-it-together-?action=lesson_resume

<In what way does your code behave incorrectly? Include ALL error messages.>
The programs doesn’t produce the correct code everything the string “Charlotte” and any number are used as arguments for the trip_cost function.

<What do you expect to happen instead?>
For example, I expected to get 1243 for trip_cost(“Charlotte”, 6), but I got 1240 instead.

```python

Replace this line with your code.
def hotel_cost(nights):
cost = 140 * nights
return cost

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 and days < 7:
cost -= 20
return cost

def trip_cost(city, days):
total = rental_car_cost(days) + hotel_cost(days) + plan_ride_cost(city)
return total

<do not remove the three backticks above>

#2

It seems odd that you are getting anything considering the above error.


#3

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