if elif and else conditions in python
if we want to check the condition during the execution of program we can use if,elif and else statement in python . they are also known as conditional statements
syntax:
if condition:
#block of codes
elif condition:
#block of code
else:
#block of code Example : Suppose we want to check the credibility of the voters in the election then it is essential to use conditional statements .
Get Biswas Banstola’s stories in your inbox
Join Medium for free to get updates from this writer.
Workflow for above example:
- take age as an input .
- check if the age is: age < 0
- print age is not negative
- if the age is : age>18
- print eligible
- else :print age cant be the negative integer
implementation:
age=int(input("enter your age "))
if age<=0:
print("Invalid inputs")
elif age>0 and age<18 :
print(f"not eligible to vote for Now \n but you can vote after {18-age} years")
else:
print("you are eligible to vote !!")follow me on:



