what’s wrong with my code. Error says I need to define Plane ride cost and syntax on line 7. Any help appreciated.
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”
Hi remove the " "
around all your number
tried that still no joy and it’s saying (Oops, try again. Did you create a function called plane_ride_cost? ) can’t see why. ever question seems so hard. Thanks for your help
Hi can you post your new code ? And read this one how to format your code
To format code so it’s visible, either wrap it in single backticks for a small amount of code, or triple backticks on an otherwise blank line before and after for a large amount of code.
Here you go.
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
103160
April 11, 2016, 2:02pm
7
will tht help tho umm confused …
103160
April 11, 2016, 2:04pm
8
i did but it still dsnt work for me
Hi can you post your code ?
And that topic is from 1 mounth ago… next time is better if you create a new topic.
103160
April 11, 2016, 2:11pm
10
oh ok…n sorry for the late reply
def hotel_cost(nights):
hotel_cost= 140
return 140 * nights
def plane_ride_cost(city):
if city == “Charlotte”:
return 183
elif city == “Tampa”:
return 220
elif city == “Pittsburgh”
return 222
if city == “Los Angeles”:
return 475
first here
def hotel_cost(nights):
hotel_cost= 140
return 140 * nights
you should remove the hotel_cost= 140
here
elif city == "Pittsburgh"
return 222
its missing the : after "Pittsburgh"
then here
if city == "Los Angeles":
return 475
It should be elif instead of if
103160
April 11, 2016, 2:23pm
12
i guess there is something wrong with line 5…n its not working sorry…n i wnt mindif u cnt do it…its ok…i dnt wanna trouble u
103160
April 11, 2016, 2:23pm
13
but just check if i did it right
your if and elif statement should be indent inside the function like that
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
103160
April 11, 2016, 2:28pm
15
i will try next time but thnx for the help…coz i needa go
take care n if it still dsnt work i will ask u
1 Like
103160
April 12, 2016, 9:05am
16
lol now it says theres something wrong with line 10
103160
April 12, 2016, 9:17am
17
my teacher helped me with it…n i got it right…thnx for ur help…really appreciate it
1 Like
HI sorry it was the last elif statement which had the wrong indent
..........
elif city == "Pittsburgh":
return 222
elif city == "Los Angeles":
return 475
103160
April 18, 2016, 1:16pm
19
oh its fn dnt worry… n i already did it so it dsnt matter…but thnx anyway
1 Like