How to Execute Code Based On Boolean Answer of Function in Python


In this example, we will learn how to execute code based on the Boolean answer of a function in Python.

Source Code

def my_function():
    return True

if my_function():
    print('It is True!')
else:
    print('It is False!')

Output:

It is True!

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments