I expect some sort of "there's no benefit in this, just write the current
implementation", indirectly or directly.
Currently, this is the way to remove `num` occurrences of an element from a
list:
> idx = 0
> while idx < len(the_list) and num:
> if the_list[idx] == element_to_remove:
>
On Wed, Dec 22, 2021 at 11:12 AM Jeremiah Vivian
wrote:
>
> I expect some sort of "there's no benefit in this, just write the current
> implementation", indirectly or directly.
> Currently, this is the way to remove `num` occurrences of an element from a
> list:
> > idx = 0
> > while idx < len(t
Currently list.remove raises ValueError if the element is not in the list.
When called with the count argument, should it raise ValueError if there
are fewer than `count` occurrences of the element in the list?
Best wishes
Rob Cliffe
On 22/12/2021 00:09, Jeremiah Vivian wrote:
I expect some s
On 2021-12-22 01:53, Rob Cliffe via Python-ideas wrote:
Currently list.remove raises ValueError if the element is not in the list.
When called with the count argument, should it raise ValueError if there
are fewer than `count` occurrences of the element in the list?
There's str.replace and str.s
> When called with the count argument, should it raise ValueError if there
> are fewer than `count` occurrences of the element in the list?
No, it shouldn't. It would raise ValueError if the element is not found within
the list though.
___
Python-ideas