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:
@ -32,6 +32,18 @@ Traceback (most recent call last):
|
|||||||
File "<stdin>", line 1, in <module>
|
File "<stdin>", line 1, in <module>
|
||||||
ValueError: list.remove(x): x not in list
|
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:
|
||||||
More information about `remove()` can be found <a href='https://docs.python.org/3.6/tutorial/datastructures.html' target='_blank' rel='nofollow'>here</a>
|
More information about `remove()` can be found <a href='https://docs.python.org/3.6/tutorial/datastructures.html' target='_blank' rel='nofollow'>here</a>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user