how to create an empty 2d list in python
#To create an empty 2d list of size n
l=[]
for i in range(n):
l.append([])
#To create an 2d list of size rows and columns
l=[[0 for j in range(len(column))]for i in range(len(row))]
how to create an empty 2d list in python
#To create an empty 2d list of size n
l=[]
for i in range(n):
l.append([])
#To create an 2d list of size rows and columns
l=[[0 for j in range(len(column))]for i in range(len(row))]
2d array python initialize
>>> b = [['a']*3]*3
>>> b
[['a', 'a', 'a'], ['a', 'a', 'a'], ['a', 'a', 'a']]
>>> b[1][1]
'a'
>>> b[1][1] = 'b'
>>> b
[['a', 'b', 'a'], ['a', 'b', 'a'], ['a', 'b', 'a']]
2d array python initialize
[[element] * numcols] * numrows
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us