simple question:the count of array

Terry Reedy tjreedy at home.com
Tue Jul 31 12:00:07 EDT 2001


"sdf" <wqh-2 at 263.net> wrote in message
news:mailman.996583454.15942.python-list at python.org...
> >>> a=['a','b','c']
> >>> b=a.count()
> Traceback (most recent call last):
>   File "<pyshell#9>", line 1, in ?
>     b=a.count()
> TypeError: count() takes exactly 1 argument (0 given)

a.count(item) counts the number of occurences of item in a.

a.count('b') = 1; a.count('x') = 0

Terry J.Reedy






More information about the Python-list mailing list