Program to create a 2D List
What is a 2D List?
A two dimensional list is a list having all its elements as lists of same shapes, i.e., a two dimensional list is a list of lists
#program to create a 2D list
l=[]
r=int(input("How many rows?"))
c=int(input("How many columns?"))
for i in range(r):
row=[]
for j in range(c):
elem=int(input("Element"+str(i)+","+str(j)+":"))
row.append(elem)
l.append(row)
print("List created is:",l)
Comments
Post a Comment