If you want to count all members of the list without specifying which one to count, you could use this reasonably standard count method (this is from the Natural Language Toolkit's online Python tutorial: http://nltk.org/doc/en/programming.html)
-
alist = [1,2,3,4,4,4]
-
-
count = {}
-
for thing in alist: # iterates though each member of your list
-
if thing not in count: # checks to see if member already exists in the count
-
count[thing] = 0 # if a member has not been counted yet, start an entry for it
-
count[thing] += 1 # each time you see a member, add one to its count
-
-
print count
-
Output = {1: 1, 2: 1, 3: 1, 4: 3}
This says "the number "1" was found once; the number "2" was found once; the number 3 was found once; the number "4" was found three times.