else if Statement in Python

Indentation plays an important role in else if Statement in Python. elif refers to else if statement in Python.

Example:

#Expecting age value from the employee
strAge = input(
    'Please share your age'
);
#Converting string to integer
intAge = int( strAge );
#Printing the voting ability
if intAge < 18 :
    print(
        'You are not eligible for voting.'
    );
elif intAge <= 58:
    print(
        'You are eligible for voting.'
    );
else :
    print(
        'You are a senior citizen with Voting rights.'
    );
print( 'Thank you!' );

Leave a Reply