Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mh0w/f226bca6f1d0d1e12410581fca94eeee to your computer and use it in GitHub Desktop.

Select an option

Save mh0w/f226bca6f1d0d1e12410581fca94eeee to your computer and use it in GitHub Desktop.
remove all occurrences of an element in a list
l = [1,2,3,2,2,2,3,4]
print(list(filter(lambda x: x != 2, l))) # [1, 3, 3, 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment