When there are multiple conditions which needs to be evaluated, use elif statements.
The flow is like, if this condition is not true, try next till the final else block is not encountered.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# Creating a variable x=10 # Condition-1 if(x>15): print("condition is true!") # creating another variable y=100 print(y) # Condition-2 elif(x>50): print('x is less than 8!') # Condition-3 elif(x==10): print('x is equal to 10!') # Everything above is false then what else: print('this is the end game!') |
Sample Output

Author Details
Lead Data Scientist
Farukh is an innovator in solving industry problems using Artificial intelligence. His expertise is backed with 10 years of industry experience. Being a senior data scientist he is responsible for designing the AI/ML solution to provide maximum gains for the clients. As a thought leader, his focus is on solving the key business problems of the CPG Industry. He has worked across different domains like Telecom, Insurance, and Logistics. He has worked with global tech leaders including Infosys, IBM, and Persistent systems. His passion to teach inspired him to create this website!
