Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to end if else statement in python

#We enclose our nested if statement inside a function 
#and use the return statement wherever we want to exit.

def something(i):
    if i%2 == 0:
        if i == 0:
            return
        if i > 0:
            print("even")

if __name__ == "__main__":
    something(0)
    print("Broken out")
    
#'Broken out'    
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #statement #python
ADD COMMENT
Topic
Name
8+4 =