Image


elif



Avi Bhattacharya



You can use another conditional statement called elif which basically gives a an alternative set of conditions. If the input doesn't meet the previous requirements, you can use as many elif statements as you want to create alternative conditions.


    x = 15
    if x > 15:
    print('x is greater than 15')
    elif x <= 15: #second condition- if the first condition isnt true then it checks whether this condition has been met. 
    print('x is less than or equal to 15')
                                                                                                      
x is less than or equal to 15


That's it for this tutorial! Click Next to access the next tutorial!

❮ Back

Next ❯









Copyright © 2021, Q-Programming | Created by Arjun Sodhi, Balpreet Juneja and Sammarth Kumar | Developed and Designed by Sammarth Kumar