[New-bugs-announce] [issue29756] List count() counts True as 1

Alexander Todorov report at bugs.python.org
Wed Mar 8 09:03:53 EST 2017


New submission from Alexander Todorov:

When using list.count() I get the following results

    >>> [1, 2, 3].count(1)
    1
    >>> [1, 2, 3, True].count(2)
    1
    >>> [1, 2, 3, True].count(True)
    2
    >>> [1, 2, 3, True].count(1)
    2

as you can see True is considered the same as 1.  The documentation for the count method says:

    count(...)
        L.count(value) -> integer -- return number of occurrences of value

so IMO the above behavior is wrong. Seeing this on a RHEL 7 system with 
Python 3.5.1 and 2.7.5

----------
messages: 289235
nosy: Alexander Todorov
priority: normal
severity: normal
status: open
title: List count() counts True as 1
versions: Python 2.7, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29756>
_______________________________________


More information about the New-bugs-announce mailing list