7/7 not printing


#1

Don't know why last line doesn't work.

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(city, days, spending_money):

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

It says Oops, try again. It looks like nothing was printed to the console!


#2

Hi, @scriptjumper91485 ,

Make sure this is not indented, otherwise, it will be part of a code block, such as a function, and will not get executed, unless the code block is executed ...

print trip_cost("Los Angeles", 5, 600)

#3

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

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

print trip_cost("Los Angeles", 5, 600)


#4

Thank you for replying. The problem was with this part of code:

if city == "Charlotte":
return 183
if city == "Tampa":
return 220
if city == "Pittsburgh":
return 222
if city == "Los Angeles":
return 475

I wrote if instead of elif.