While use all()and your specific function is a good way to do this, you can also explore this alternative
>>> from itertools import chain
>>> sum(1 for e in chain(*[[1,1,1], [1,1,1], [1,1,1]]) if e!= 1)
0
or you can also call allOnesafter expanding the list throughitertools.chain
>>> allOnes(chain(*[[1,1,1], [1,1,1], [1,1,1]]))
True
>>>
source
share