Program to Create 2D Array || 2D Array || Python

In this we are going to see a basic program to create 2D Array in Python programming Language.


n = 3
m = 4

a = [[0] * m] * n
for i in a:
    print(i)

print()

b = [0] * n
for i in range(n):
    b[i] = [0] * m
for i in b:
    print(i)

print()

c = [[0] * m for i in range(n)]
for i in c:
    print(i)


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post