Added example code with duplicates in list (#23629)

* Added example code with duplicates in list

* Reworded sentence to introduce duplicates
This commit is contained in:
raviram
2018-11-29 06:21:55 +05:30
committed by Manish Giri
parent b5bef94354
commit 9b76a135e4

View File

@ -32,6 +32,18 @@ Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: list.remove(x): x not in list
```
If there are duplicate elements in the list, the `remove()` function removes the first occurrence of the element.
```py
numbers=[1,2,3,4,5,1,6]
numbers.remove(1)
print(numbers)
```
#### Output
```py
[2,3,4,5,1,6]
```
#### More Information:
More information about `remove()` can be found <a href='https://docs.python.org/3.6/tutorial/datastructures.html' target='_blank' rel='nofollow'>here</a>