mardi 4 septembre 2018

unexpected syntax error on 'else' while the code seems correct

def restudy():
    print "OK, since you decided to restudy at MIANYANG high school, you must work hard!"
    print '''
    Now, it's time to determine your destiny.
    Please answer the questions below:
    what's the result of 1+1? 
    if you give the right answer, you can go to Shanghai; but if you can't
    you'll be caught in here forever.
    '''

    test = raw_input("> ")

    if test == "2":
        print "you succeed!"
        shanghai()
    else: # that's the error line
        restudy()

And that's the result terminal shows to me:

 else:
        ^
 SyntaxError: invalid syntax

what's the problem about my code? cuz I think it seems right. hope someone could help me out. thanks!

Aucun commentaire:

Enregistrer un commentaire