simple question:the count of array
Chris Barker
chrishbarker at home.net
Tue Jul 31 13:23:50 EDT 2001
Jay O'Connor wrote:
> > >>> 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)
> I'm not sure what "count()" does, but to get the number of values in an
list.count(x) returns how many instances of x are in list.:
>>> a.count('b')
1
>>> a.append('b')
>>> a
['a', 'b', 'c', 'b']
>>> a.count('b')
2
-Chris
--
Christopher Barker,
Ph.D.
ChrisHBarker at home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------
More information about the Python-list
mailing list