Skip to main content

#mastery17 Use of “elif” with a conditional

1 min read

This is similar to an "else" but instead of doing something if the first condition is not fulfiled, this will make another condition in case the first one isnt fulfiled. For example:

num=2

if (num>3):

print ("Hello") #  wont print this because the condition is not fulfiled (false)... this line must be idented so it can be part of the "if"

elif (num==2):

print ("Goodbye") # the condition wasnt fulfiled the "elif" will take place and it'll print Goodbye... this line must be idented so it can be part of the "elif"