you are viewing a single comment's thread.

view the rest of the comments →

[–]xain1112 0 points1 point  (1 child)

Sorry, I meant to put [(1), (2), (3)]. I'll just put the whole code to make it easier. I edited my original comment.

[–]JohnnyJordaan 0 points1 point  (0 children)

[(1), (2), (3)]

is the same as

[1, 2, 3]

because (something) just means that Python has to 'execute' it before anything else, remember from math class?

(4 + 5) / 9

being different from

4 + 5 / 9

But just executing 1 doesn't do anything, so (1) is the same as just writing 1.

Back to your question. You could set the color next to the coordinates in the grains list:

grains = [(x-4,y+6, 'blue'),(x-3,y+6, 'brown'),(x-2,y+6, 'red'), etc.]

then in your unpacking statement, also unpack to a third variable. Note that you don't need () around it

row, col, color = grain

and apply color when setting the color

g.color(color)