[Solved] Python lambda returns true even with a false condition


You’re not calling your lambda as I’ve explained in my comment, but if you want it inline you can test as:

if (lambda x: True == True)(None):
    print("yes")  # prints

if (lambda x: False == True)(None):
    print("yes")  # doesn't print

Or more general, since you’re not actually using any arguments in your lambdas:

if (lambda: True == True)():
    print("yes")  # prints

if (lambda: False == True)():
    print("yes")  # doesn't print

3

solved Python lambda returns true even with a false condition