index

If statement

if <condition>:
    #True here
    statements
elif <condition>:
    #True here
    statements
…
else:
     #Catch all other here
     statements

Example:

if a['a']==1:

print\('yes'\)

elif a['a']==2:

print\('no'\)

else:

print\('unknown'\)

Last updated