Arrays in Python

I am an ex RF engineer with limited software knowledge. I am currently trying to use a Plasma 2040 to create a background illumination that slowly changes (updates about every 15 minutes) in both colour and intensity throughout the day. I had hoped to use an array to hold RGB values (since I understand arrays) and would use each row as a separate time value of RGB colour and brightness. I am told that Python does not handle arrays and uses lists instead. Anyone any idea how I can bridge the gap !! I would want to be able to modify the data values from time to time to create different background scenarios and don’t fancy modifying a list with about 384 different values.

For the most part Python lists will act as you would expect arrays. Been a while since I touched Python so this might not be the most elegant, but I think it does what you need - it creates a 10x3 array which can be modified using array indices.

list = []
for i in range(0,10):
    list.append([0,0,0])
list[0][0] = 255
print(list)

Prints:

[[255, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]

Thank you major_tomm, you have got me further down the road than I expected to be

1 Like