Counting the occurrences of one item in a sequence list.count and tuple.count
suggest changealist = [1, 2, 3, 4, 1, 2, 1, 3, 4]
alist.count(1)
# Out: 3
atuple = ('bear', 'weasel', 'bear', 'frog')
atuple.count('bear')
# Out: 2
atuple.count('fox')
# Out: 0
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents