Skip to content

Files

Latest commit

 

History

History
35 lines (24 loc) · 548 Bytes

File metadata and controls

35 lines (24 loc) · 548 Bytes

Pattern: Malformed comparison to True

Issue: -

Description

When comparing a variable to True, you should use the form if x is True or simply if x. The most common incorrect form is if x == True.

Example of incorrect code:

x = True
if x == True:
    print('True!')

Example of correct code:

x = True
if x is True:
    print('True!')

or simply:

x = True
if x:
    print('True!')

Further Reading