You may want to look into using a python set
:)
Example with code:
# set cannot have duplicates
# Output: {1, 2, 3, 4}
my_set = {1, 2, 3, 4, 3, 2}
print(my_set)
# we can make set from a list: what you want
# Output: {1, 2, 3}
my_set = set([1, 2, 3, 2])
print(my_set)
Then you can use remove
or discard
(if you don't want errors upon removing non-existing items):
my_set = {1, 3, 4, 5, 6}
print(my_set)
# discard an element
# Output: {1, 3, 5, 6}
my_set.discard(4)
print(my_set)
# remove an element
# Output: {1, 3, 5}
my_set.remove(6)
print(my_set)
# discard an element
# not present in my_set
# Output: {1, 3, 5}
my_set.discard(2)
print(my_set)
# remove an element
# not present in my_set
# you will get an error.
# Output: KeyError
my_set.remove(2)
If you prefer to work with a list, then you can then convert back to a list with the list
function:
my_list = list(my_set)
Docs: https://python-reference.readthedocs.io/en/latest/docs/sets/