The code keeps telling me It looks like plane_ride_cost does not return 183 when the city is Charlotte


#1



Planning a Vacation 3.Getting There


the code keeps telling me "It looks like plane_ride_cost does not return 183 when the city is Charlotte" but I don't see the problem, the code looks fine to me. I also wrote a code that says that the city is Charlotte. city = "Charlotte" and i wrote it inside the function


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"
     city ="Charlotte"


#2

Read instruction once again and check if we have to return an integer or a string at particular city match ?


#3

Its says that I should define a function called plane_ride_cost that takes a string, city, as input.
I got stuck here for a while because a string should be in quotes right ? so should it be def plane_ride_cost("city"): instead ?


#4

Check this list..
plane_ride_cost("city"):
No, that's right without quotes.

Look at this..

"Charlotte": 183
"Tampa": 220
"Pittsburgh": 222
"Los Angeles": 475

183 is an integer but "183" is string, right ?


#5

Here is the instructions Below your existing code, define a function called plane_ride_cost that takes a string, city, as input.
The function should return a different price depending on the location, similar to the code example above. Below are the valid destinations and their corresponding round-trip prices.
"Charlotte": 183
"Tampa": 220
"Pittsburgh": 222
"Los Angeles": 475


#6

Like this one of the code,
It should have returned 183 but its returning "183" ?
any difference?

(We can go with that code too but then we will have to use str() constructor while calling this function)


#7

after changing the string to an integer it now says It looks like plane_ride_cost does not return 220 when the city is Tampa. :confounded:


#8

Have to change all.

like

"220" --> 220
"222" --> 222

and so on...


#9

I did that thought

def hotel_cost(nights):
    return 140 * nights
def plane_ride_cost(city):
    if city == "Charlotte":
        return 183
    elif city == "Tampa":
        return 222
    elif city == "Pittsburgh":
        return 222
    elif city == "Los Angeles":
        return 475

#10

Check error message and check your code, what error says .

It looks like plane_ride_cost does not return 220 when the city is Tampa.


#11

It just says None. , should i skip this one and go to the 4th lesson maybe it's a bug or something ?


#12

For tampa you're returning 222 and for Pitssburgh too?
check the list again..

"Charlotte": 183
"Tampa": 220
"Pittsburgh": 222
"Los Angeles": 475

#13

i wrote 222 in Tampa instead of 220..i missed up, this is embarrassing :Q sorry man i wasted your time

It worked. Thanks


#14

It's all good pal! :wink:
while hunting a bug ,we need to be a bit patient.
we finally found that and solved that tho. :thumbsup:


#15

No it should not be. it is:
def plane_ride_cost(city)


#16

The cities are in quotes because they are strings, the returns are not in quotes, because they are integers.


#17

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