May-09-2022, 06:51 PM
(This post was last modified: May-09-2022, 06:51 PM by Gribouillis.)
turtles[i].forward(randint(0, 5))saves a line. I think the index i should be increased before the forward move.
codingcat Wrote:Does python let you separate commands with a commaIf you separate expressions by commas on a line, it creates a tuple, for example
2 ** 2 , 2 ** 3, 2 ** 4creates the tuple
(4, 8, 16)
and then deletes it immediately because it is not assigned to any variable.@menator01 you could even write with the walrus operator
turtles[i := (i + 1) % len(turtles)].forward(randint(0, 5))