#1

Hi, everybody. I have an error "Oops, try again. It looks like nothing was printed to the console!" in this code. Can anyone give me the solution pls?

Here's the 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):
if days >= 7:
return 40*days - 50
elif days >= 3 and days < 7:
return 40*days - 20
else:
return 40*days
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)

#2

I have found the solution already. Close the topic pls.

#3

could you share the solution?.. Thanksss

#4

``````def hotel_cost(nights):
return 140 * nights
# cost of hotel times number of night's stay

def plane_ride_cost(city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh":
return 222
else:
return 475
# cost of flight based on destination

def rental_car_cost(days):
cost = days * 40
if days >= 7:
cost -= 50
elif days >=3:
cost -= 20
return cost
# cost of rental car depending on days in possession

def trip_cost(city, days, spending_money):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money
# total cost of the trip

print trip_cost("Los Angeles", 5, 600)
# printed cost of trip``````

#5

Thanks man, The code works perfectly... But I have a question. We don`t have to def "spending money" before to include this in the trip__cost fuction?..Thanks again for your attention...

#6

i guess we have already declared spending_money in the function trip_cost in the above code

#7

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