Sometimes, we need to remove an item from a list. So, this can be accomplished by using the remove () method. The syntax for the method is given as follows:
list.remove(item)
The remove () method is used to remove an item from a list. For example, consider the following example:
>>> Avengers1 = ["Iron-man","Thor","Loki","hulk"]
>>> Avengers1.remove ("Loki")
>>> Avengers1
['Iron-man', 'Thor', 'hulk']
>>>
>>>
Because "Loki" was not a member of the Avengers team, we removed it.
Let's consider another example:
>>> num = [1,2,3,4,5,6,4,1,7]
>>> num.remove(1)
>>> num
[2, 3, 4, 5, 6, 4, 1, 7]
>>>
In the preceding example, you can see that the remove () method just removed the first occurrence.