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 add elements inside a list using append
l=[]
n=int(raw_input('Enter the no of elements added to list:'))
for i in range(n):
element=int(raw_input('Enter the elements:'))
l.append(element)
print l
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
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)