Python Forum

Full Version: Syntax Error (elif statement)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I’m following a tutorial on youtube on how to code a very simple game.
The part of my code which recieves the error looks like this:
player_choice = input()

if player_choice == '1':
    monster['health'] = monster['health'] - player['attack']
    player['health'] = player['health'] - monster['attack']

edit 2: Nvm I solved i, forgot parantheses at player health
    print(monster['health'])
    print(player['health']
elif player_choice == '2':
    print(Heal Player)
else:
    print(Invalid Input)
The error I recieve:
    elif player_choice == '2':
    ^
SyntaxError: invalid syntax
I’ve compared my codes with the tutorial and it is almost exactly identical
Heres the video for reference: https://youtu.be/kDdTgxv2Vv0?t=1843

edit: This is what's stated in the "problems" tab in VS code (line 15 in VS code being Line 8 in here, since I cut some of the code out ofc):
"message": "invalid syntax (<unknown>, line 15)"