fork download
  1. #!/usr/bin/env python
  2.  
  3. def lcount(l):
  4. count = 0
  5. if type(l) == type([]):
  6. count+=1
  7. count+=sum([lcount(x) for x in l])
  8.  
  9. return count
  10.  
  11.  
  12. list_ = [ [ [1, 2, 3], [1, 4, 5], [7, 8, 9]], [ 1, 2, 7], 1, 3, ]
  13. print lcount(list_)
Success #stdin #stdout 0.01s 7852KB
stdin
Standard input is empty
stdout
6