Answers for "empty 2d array 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

initialise a 2d array python

x = [[foo for i in range(10)] for j in range(10)]
# x is now a 10x10 array of 'foo' (which can depend on i and j if you want)
Posted by: Guest on April-16-2020

Python Answers by Framework

Browse Popular Code Answers by Language