#mastery16 Use of “else” with a conditional

This is the alternate ending to an if function. If the condition is not fulfiled you put an “else” and it will do what is inside of that “else” 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”

else :

print (“goodbye”) the condition wasnt fulfiled the “else” will take place and it’ll print goodbye… this line must be idented so it can be part of the “else”

This program will show the user:

goodbye

 

CC BY 4.0 #mastery16 Use of “else” with a conditional by Gilberto Rogel García is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.