"It's me" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> What's the best way to count number of items in a list? > > For instance, > > a=[[1,2,4],4,5,[2,3]] > > I want to know how many items are there in a (answer should be 7 - I don't > want it to be 4) How about this? def totallen(x): if isinstance(x, (list, tuple, dict)): return sum(map(totallen, x)) return 1 -- http://mail.python.org/mailman/listinfo/python-list