0

Suppose that I have a list like this :

test=[[1, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 0, 1],
    [0, 0, 1, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1],
    [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1],
    [1, 0, 0, 0], [1, 0, 0, 0],[0,0,0,0]]

How can I count the number of occurrences of say the list [1, 0, 0, 0]?

Aran-Fey
  • 35,525
  • 9
  • 94
  • 135

1 Answers1

4

Use list.count:

test.count([1,0,0,0])
miindlek
  • 3,485
  • 13
  • 25