0

Why isn't my code alternating and it always takes the green color?

import turtle t = turtle.Turtle() t.speed(1) t.width(2.5) for bs in range(4): t.color("red") t.forward(80) t.penup() t.forward(20) t.pendown() t.right(90) for nsss in range(4): if nsss%2 == 0: t.color("blue") else: t.color("green") for side in range(4): t.forward(20) t.right(90) t.penup() t.forward(23) t.pendown()

16th Nov 2022, 10:51 AM
Kerolos Riad
Kerolos Riad - avatar
4 odpowiedzi
+ 1
You are not doing any drawing in the loop, you just set the color. So after the loop it is green.
16th Nov 2022, 11:10 AM
Lisa
Lisa - avatar
+ 1
Alr .. I figured it out ^⁠_⁠^
16th Nov 2022, 2:53 PM
Kerolos Riad
Kerolos Riad - avatar
0
Take a look again i added the whole code!..I just want it to pick a different color between blue & green each time
16th Nov 2022, 11:22 AM
Kerolos Riad
Kerolos Riad - avatar
0
Lisa then how do i alternate between them and pick a color then draw with it then pick the other color and draw🔁?
16th Nov 2022, 1:20 PM
Kerolos Riad
Kerolos Riad - avatar