[issue40809] list.Count() isn't working as expected for the series of same numbers in a list

Rémi Lapeyre report at bugs.python.org
Thu May 28 12:39:12 EDT 2020


Rémi Lapeyre <remi.lapeyre at henki.fr> added the comment:

Hi cmaliwal! You are mutating the list while iterating over it which can lead to all sorts of issues, to keep the unique elements of a list you can do 


>>> a = [1, 1, 1, 1]
>>> list(set(a))
[1]


If you think you found a bug in Python please check in the python-help mailing list or StackOverflow.

----------
nosy: +remi.lapeyre
title: list.count() isn't working as expected for the series of same numbers in a list -> list.Count() isn't working as expected for the series of same numbers in a list

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40809>
_______________________________________


More information about the Python-bugs-list mailing list