0

If I have an boolean variable such as:

condition = True

And it is used in an if statement, is there any diference between the uses (other then readability)? For example:

if condition:
    pass

if condition == True:
    pass

if condition is True:
    pass
user118799
  • 21
  • 7
  • Don't use `elif` when the condition is the opposite of the `if` condition. Just use `else:` – Barmar Apr 08 '22 at 17:32
  • @JohnnyMopp That's OK because `if condition` succeeds for all the other values. – Barmar Apr 08 '22 at 17:34
  • @Barmar Yes, just threw that in for good measure. Anyway, now that I see the dupe, my comment is not needed. – 001 Apr 08 '22 at 17:34
  • I just added the elif statement to explain better what was my point. But i'll edit it out, because it realy doesn't make much sense to be there – user118799 Apr 08 '22 at 17:54

0 Answers0