"Taking a Vacation" What am i doing wrong?


#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.>

<In what way does your code behave incorrectly? Include ALL error messages.>

name ‘days’ is not defined

<What do you expect to happen instead?>

i expected it to return the cost of 5 days in Los Angeles with $600 spending money

```python

Replace this line with your code.

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 and days < 7:
    cost -= 20
  return cost
    
def trip_cost(city,days,spending_money):
    return rental_car_cost(days) + hotel_cost(days) + 			plane_ride_cost(city) + spending_money
  
print
trip_cost("city",days,spending_money)
city = "Los Angeles"
days = 5
spending_money = 600
<do not remove the three backticks above>

#2
print
trip_cost("city",days,spending_money)

you should call the trip_cost function with print statement at same line.

city is not a string value.we don’t need "" for it. pass a string value.
and here

city = "Los Angeles"
days = 5
spending_money = 600

you can directly call the function passing the arguments.don’t need to create variables.

but if you still want then create it before you use it.


#3

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