Answers for "how to create an empty 2d list in python"

0

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))]
Posted by: Guest on July-30-2021
0

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']]
Posted by: Guest on December-07-2020
-1

2d array python initialize

[[element] * numcols] * numrows
Posted by: Guest on December-07-2020

Code answers related to "how to create an empty 2d list in python"

Python Answers by Framework

Browse Popular Code Answers by Language