Whenever I write elif or else in my code I get a Syntax Error. Why is this?

Question:

I am trying to write code for a simple Rock Paper Scissors and I got stuck here because else or elif don’t work in my code. This is my code

I tried looking up why this didn’t work and I couldn’t find anything on the subject.

Asked By: OmniCrownMagus

||

Answers:

It seems you are mixing the order how to use ifelifelse.

The following is quoted from
if, elif and else.. priority and chains (I recommend reading it fully):

else is the catch-all after all the if and elif statements were False. Putting it in the middle would be a syntax error.

To demonstrate how the ifelifelse blocks work:

if False:
    print 'first'
elif True:
    print 'second'
elif True:
    print 'third' "
Answered By: Monco
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.