Python for Engineers
Solve Problems by Coding Solutions - A Complete solution for python programming
Blog Pages
Blog
News
Distributions
NumPy Tutorials
Self Learning
IDE
Packages
About
To count the elements in a nested list with all elements are list
a=[[3, 4, 5,8, 8 ], [5, 6, 7], [7, 8, 9]]
def count(a):
j=0
n=0
for b in a:
j=len(b)
n=n+j
return n
t= count(a)
print "No elements in the nested list are:",t
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment