Pull it togeather is so broken or im an idiot


#1



Replace this line with your code.


#2

What exactly do you need help in @jcrew504?


#3

sorry bou the mess up there.
i just cant figure out whats wrong with my code everything worked fine till this part

error: rental_car_cost returns non when is should return 40

the problem is it returned 40 befor why now is it broken

def hotel_cost(nights):
return 140 * nights

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

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

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


#4
> def hotel_cost(nights):
>     return 140 * nights
>     
> def plane_ride_cost(city):
>     if city == 'Tampa':
>         return 220
>     elif city == 'Charlotte':
>         return 183
>     elif city == 'Pittsburgh':
>         return 222
>     elif city == 'Los Angeles':
>         return 475
>         
> def rental_car_cost(days):
>     cost = days*40
>     if days >= 7:
>         cost = days*40 - 50
>     elif days >= 3:
>         cost = days*40 - 20
>     print cost

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

#5

Hello @jcrew504,

In your rental_car_cost function, you haven't returned anything. Modify your code to return cost, and you'll be good to go...


#6

this worked for me:

def hotel_cost(nights):
return 140.0*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):
renting_cost = days*40
if days>=7:
renting_cost -=50
elif days<=7 and days>=3:
renting_cost -=20
return renting_cost
def trip_cost(city,days):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)