Answers for "python 2d array initialize"

3

python initialize a 2d array

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 November-09-2020
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
0

intialize 2d aray in python

[[foo for x in xrange(10)] for y in xrange(10)]
Posted by: Guest on September-12-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
0

python initialize a 2d array

bar = [SOME EXPRESSION for item in some_iterable]
Posted by: Guest on November-09-2020

Code answers related to "python 2d array initialize"

Python Answers by Framework

Browse Popular Code Answers by Language