Use a Boolean variable inside function which always return returns a value True or False in Python. Set initial value of variable true and false then change it according to the conditions.
Example function returns Only True or False value in Python
Simple example code gets the true or false return value.
def foo(a, b):
answer = False
if a > b:
answer = True
return answer
print(foo(12,3))
Output:

Do comment if you have any doubts and suggestions on this Python function program.
Note: IDE: PyCharm 2021.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.