pythonsyntax-erroradventure

Why am I getting a syntax error for using an input within an elif statement?


I'm currently working on a text based game for a school project. I keep getting an invalid syntax error for the part that says 'reply'. Would you know why this may be? I've used this method a lot throughout the game and this is the first time i'm getting this error.

print("You decide it's time to look for a way out of this place. You consider travelling upstream to investigate where the wallet came from. You also remember being told that all rivers will eventually lead to a town or village.")
direction = input("Do you travel a)upstream or b)downstream? >")
if direction == "upstream" or direction == "Upstream" or direction == "Up" or direction == "up" or direction == "travel upstream" or direction == "Travel upstream":
      print("You travel upstream")
elif direction == "downstream" or direction == "Downstream" or direction == "Down" or direction == "down" or direction == "travel downstream" or direction == "Travel Downstream":                                        
      print("You travel downstream. You walk for hours but the river does not lead anywhere. It gets dark and you can no longer find your way. You decide to rest until morning.")
      print("You are suddenly woken from your sleep by a familiar voice. It's your", spouse+"!")
      print(spouse_name.upper()+":", '"'+name_f+"!?",'What are you doing here?'
      reply = input("Enter 1 for 'What are you doing here??' Enter 2 for 'I don't know, I just woke up here' >")
      if reply == '1':
            print(name_f.upper()+':',"What are you doing here??")
            print(name_f.upper()+':',"I
      elif reply == '2':
            print(name_f.upper()+':',"I don't know, I just woke up here")
            print(name_f.upper()+':',"I don't remember anything, I don't remember how I got here"
      print(spouse_name.upper()+":", "How are you still alive?"
      print(name_f.upper()=':', spouse_name+',','what are you talking about??')
      print("before you have time to realise what's going on,", spouse,"pulls out a gun and shoots you in the head")
      print("GAME OVER")

Solution

  • In this part of the code:

     print(name_f.upper()+':',"I
     elif reply == '2':
    

    You aren't ending your print statement or your string, unfinished work I suppose. Therefore, the rest of the code is treated as a string, the string has no end and the print statement has no closing parentheses.

    Programmers make these mistakes all the time but as you get more and more experienced you need to catch these mistakes.