Skip to content

Files

Latest commit

 

History

History
27 lines (18 loc) · 519 Bytes

File metadata and controls

27 lines (18 loc) · 519 Bytes

Pattern: Missing use of not in for membership test

Issue: -

Description

Tests for membership should use the form x not in the_list rather than not x in the_list. The former example is more readable.

Example of incorrect code:

my_list = [1, 2, 3]
if not num in my_list:
    print(num)

Example of correct code:

my_list = [1, 2, 3]
if num not in my_list:
    print(num)

Further Reading