Really can't understand why i stuck here..!


#1


code starts here

nights = 3
def hotel_cost(nights):
return plane_ride_cost(city) * nights

def plane_ride_cost(city):
if city == Charlotte:
return 183
elif city == Tampa:
return 220
elif city == Pittsburgh:
return 222
elif city == LosAngeles:
return 475
else:
return invalid_city

end of code

Error:Have you created function called plane_ride_cost().


I think it should run perfectly.


Replace this line with your code.


#2

First think I see is since you don't have the city names in quotes, they are trying to see if they are equal to variable that you haven't made. You want to check if the input of the code is equal to the string "Charlotte" etc. Also, invalid_city is not a variable either. That needs to be in quotes to return a string.


#3

ok thnks very much bro...
now tell me one thing how can i see the output on my screen .i.e console
in otherwords how can i see the output of 2 night * any city cost.
e,g if nights = 2
and city = "Tampa"
then i want ans = 2 * 220 = 440.


#4

Since you are returning the value instead of printing it inside the function, you can call print on the function.

print plane_ride_cost("Tampa")

I think you have more to do in this lesson though. You will end up writing a function that calculates the plane, the hotel per nights, and a rental car automatically.


#5

thnks for ur guidence, i'll keep you updating..!!


#6

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