Re: 'int' object does not support item assignment
Posted: Wed May 24, 2017 10:46 am
Not sure how you figured out that `s1 = 60,2` would create a 60x2 array, that command creates a tuple with the value (60, 2)
If you want to create an array of a pre-defined size where each element is preset to zero the following code will work
(Python is a bit clunky here and for defining arrays people often use numpy https://docs.scipy.org/doc/numpy/refere ... umpy.zeros)
If you want to create an array of a pre-defined size where each element is preset to zero the following code will work
Code: Select all
w = 60
h = 2
array = [[0 for x in range(w)] for y in range(h)]