Even an engineer can't fly a plane just by reading a book!


#1


https://www.codecademy.com/courses/python-beginner-P5YtY/1/2?curriculum_id=4f89dab3d788890003000096

File "python", line 8
elif city == "Tampa"
^
SyntaxError: invalid syntax

Codecademy proves human teachers will always have job security.

Can someone please explain the error? I've indented forward and back. I've copied and pasted "correct" code and still get the same error. Telling someone its wrong without explaining WHY doesn't tell them HOW to do it correctly next time.


def plane_ride_cost (city):
    
    if city == "Charlote": 
        return 183    
    elif city == "Tampa"
        return 220       
    elif city == "Pittsburgh":
            return 222    
    elif city == "Los Angeles":
            return 475


#2

Well specifically your last two return statements are off from the other two so maybe space them back and try that? For mine I have them all aligned:

    if whatever:
        return whatever
    elif whatever:
        return whatever
    elif whatever:
        return whatever
    elif whatever:
        return whatever

#3

Thank you for your response!

The error message changed to:

File "python", line 8
elif city == "Tampa"
^
SyntaxError: invalid syntax

and here is my code after your suggested edit:

def plane_ride_cost (city):

if city == "Charlote": 
    return 183    
elif city == "Tampa"
    return 220       
elif city == "Pittsburgh":
    return 222    
elif city == "Los Angeles":
    return 475

When I submit code it asks did I 'create a function called plane_ride_cost?'


#4

Just caught the missing colon after Tampa but when I add that the message now says:

"Oops, try again. It looks like plane_ride_cost does not return 183 when the city is Charlotte."


#5

Misspelled Charlotte need that extra t in there ! :smiley:

Also, do you have two accounts? haha I just realized I responded to two accounts xD


#6

THANK YOU! THANK YOU! THANK YOU! THANK YOU!

I might have signed up using two different accounts but I primarily use eyesus34. Once more for good measure.....

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


#7

No problem! Glad to help ya out and happy coding! :smiley:


#8

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