if-elif-else structure : If « Language Basics « Python






if-elif-else structure

if-elif-else structure


import random

mood = random.randrange(3)

if mood == 0:
    print mood
elif mood == 2:
    print mood
else:
    print "Illegal mood value!."
           
       








Related examples in the same category

1.Nested if statementNested if statement
2.if-else structureif-else structure
3.if structureif structure
4.if Statements: if, elif and elseif Statements: if, elif and else
5.Boolean operation in ifBoolean operation in if
6.elif demoelif demo
7.if with elseif with else
8.If statement: a dictionary-based 'switch'If statement: a dictionary-based 'switch'
9.Leap Year checkerLeap Year checker