Код:
import time
from turtle import *
colors = (
('red', 'black', 'black'),
('red', 'yellow', 'black'),
('black', 'black', 'green'),
('black', 'yellow', 'black')
)
speed(0)
try:
while True:
for block in range(4):
for light in range(3):
setpos(0, - light * 100)
pendown()
color('white', colors[block][light])
begin_fill()
circle(50)
end_fill()
penup()
time.sleep(.3)
except KeyboardInterrupt:
pass
Виконати цей код на Repl.It: https://repl.it/@ttolich/trafficlights#main.py