If elif else statement in python

Updated: May 18, 2020


We use the if..elif..else statement when we need to check multiple conditions.

Syntax:

if condition:

statement1

elif condition_2:

statement2

elif condition_3:

statement3

..

..

..

else:

statement_n

Example:

num = 1234

if 9 < num < 100:

print("Two digit number")

elif 99 < num < 1000:

print("Three digit number")

elif 999 < num < 10000:

print("Four digit number")

else:

print("number is <= 9 or >= 10000")

Output:

Four digit number



11 views0 comments

Recent Posts

See All

Python Modules

A module is a file containing Python definitions and statements. A module can characterize functions, classes and variables. A module can likewise incorporate runnable code. Gathering related code int

 

9555593818

Thakurdwara, Uttar Pradesh 244601, India

  • Facebook
  • Twitter
  • LinkedIn