```
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 "Yo dont't enter the city"
def rental_car_cost(days):
if days == (1):
return(40)
if days == (2):
return (80)
if days == (4):
return (140)
if days == (5):
return (180)
if days == (6):
return (220)
if days == (8):
return (270)
if days >= (7):
return (40 * 7 -50)
elif days >= (3):
return (40 * 3 -20)
return rental_car_cost
```

# My code does not work at all, Although I think it should

**12mratcliff**#1

**mrfox3000**#3

Try this one:

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:

return cost -50

elif days >= 3:

return cost -20

return cost

(I'm not sure if this is right)

His code is correct:

Just indent the return commands:

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:

return cost -50

elif days >= 3:

return cost -20

return cost

**link_11**#6

Here's a few notes on what's actually going on.

Remember to keep things indented properly, and write yourself notes when necessary. The language is pretty self-explanatory, however, decrypting your code into plain english helps quite a bit.

What kept tripping me up, was forgetting to 'Return' my desired 'if' statements.

In the previous lesson, we defined the PLANE RIDE COST based upon "various" cities... hence the variable "(city)

We then returned each cost for each individual city, based on whatever variable is inputted.

We write

```
if city == "Charlotte": #We end our if statement with a colon
return 183 #And in that, if the input for city
#is "Charlotte" our program defines our variable
#(City) as being equal to 183
```

We have defined our various cities cost for a plane ticket.

Then we move on to rental cars, however in this exercise we have added new variables and subsets. The rental car cost is $40/day, however, if you drive the car for x amount of days you get x amount off of your total. There are two offers, in increasing value, however, unlike our city defining code, we have a set amount * the amount of days, rather than just a set amount for our cities....

Look over the first bit of code, then look at the solution and read the notes I've left.

It's very very simple, however you have to remember that you are essentially telling the computer what to do. I can tell my dog to sit, but if she cannot compute what "sit" means, then I must show her what I mean. If she knows how to sit on command, but I do not signal her to do so, then she will also, not sit...

```
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): # defines rental car cost with the variable (days)
total = 40 * days # Rental is $40/day
if days >= 7: # If rented 7 days or more, $50
return total - 50 # is deducted from total
elif days >= 3: # If rented 3 days or more, $20
return total - 20 # is deducted from total
else: # Otherwise, there is no discount
return total # Line 19's 'elif' states that offers
# cannot be combined.
```

**khaledgh**#7

def hotel_cost(nights):

return 140 * nightsdef plane_ride_cost(city):

if city == "Charlotte":

return 183

elif city == "Tampa":

return 220

elif city == "Pittsburgh":

return 222

elif city == "Los Angeles":

return 475def rental_car_cost(days):

cost = 40 * days

if days >= 7 :

cost -= 50

return cost

elif days >= 3 :

cost -= 20

return cost

else:

return costdef trip_cost(city, days, spending_money):

return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_moneyprint trip_cost("Los Angeles", 5, 600)

**this is my code and it's work, try it and understand it.****Good luck. ^^**