Pull it together-- Oops, try again. plane_ride_cost('Los Angeles') returned False instead of the correct value 475


#1

im new around here guys, recently i encountered an error strong textOops, try again. plane_ride_cost('Los Angeles') returned False instead of the correct value 475**strong text**

Here is my code, please guys help me

def hotel_cost(days):
return 140*days
def plane_ride_cost(city):
city= city.lower()
if city == "charlotte":
return 183
elif city == "tampa":
return 220
elif city == "pittsburgh":
return 222
elif city == "los Angeles":
return 475
else:
print "Enter a valid destin.."
return False
def rental_car_cost(days):
rental=40
if days>=7:
rental= (rental*days)-50
return rental
elif days<= 7 and days>=3:
rental= (rental*days)-20
return rental
else:
rental=(rental*days)
return rental
def tripcost (city, days):
return plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days)
print tripcost ("tampa", 4)


#2

Hello, @anantharamakrishnan !
There are two things on your code that I'd like to talk about:

1 -

else:
print "Enter a valid destin.."
return False

In this case, I can't say you're wrong, you're actually informing the user that he/she did wrong but returning a logical value due that, where you don't do any sort of "error handling", it will be wrong. When you return that value, you'll try to calculate it and things will go wrong.

Try to consider things will be all great and the user won't try to cause errors so you can pass the assignment and after that, you can come up with all sorts of error handling!

2 -

elif city == "los Angeles":

This could be a problem when the input is "los angeles". Even by using the .lower() function, if you inform "Los Angeles",it won't be equal to "los Angeles" due to that uppercase "A" at "Angeles".
But that would happen if someone informs Los Angeles!

Other than that, you're doing a really good job!
Keep up the good work! :+1: