how to create 2d list in python
o=[]
for i in range(0,rows):
x=[]
for j in range(0,cols):
x.append(0)
o.append(x)
#if you use [[0]*cols]*rows all rows will become the same list
#so editing in one row will edit all rows
how to create 2d list in python
o=[]
for i in range(0,rows):
x=[]
for j in range(0,cols):
x.append(0)
o.append(x)
#if you use [[0]*cols]*rows all rows will become the same list
#so editing in one row will edit all rows
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)
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