Logo

Programming-Idioms

History of Idiom 135 > diff from v44 to v45

Edit summary for version 45 by programming-idioms.org:
[Python] +DocURL, +comment

Version 44

2020-09-30, 09:18:32

Version 45

2020-09-30, 09:20:59

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic.
If there are several occurrences of x in items, remove only one of them. If x is absent, keep items unchanged.

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic.
If there are several occurrences of x in items, remove only one of them. If x is absent, keep items unchanged.

Variables
items,x
Variables
items,x
Code
items.remove(x)
Code
items.remove(x)
Comments bubble
Raises a ValueError if x is not found.
Doc URL
https://docs.python.org/3/tutorial/datastructures.html