it’s very easy to get the number of items in a list,
len(list), but say I had a matrix like:
Is there a pythonic way to return 6? Or do I have to iterate.
You can use
from itertools import chain l = [[1,2,3],[1,2,3]] len(list(chain(*l))) # give you 6
list(chain(*l)) give you flat list:
[1, 2, 3, 1, 2, 3]