Answer the question
In order to leave comments, you need to log in
How to solve the problem in code?
from threading import Thread
colours = []
th = []
por = '123'
pora = {1: 'зеленым', 2: 'желтым', 3: 'красным'}
por1 = {}
numsv = int(input('Кол-во светофоров --> '))
print('\n\t1 --> зеленый\n\t2 --> желтый\n\t3 --> красный')
for i in range(int(numsv)):
colours.append(int(input('> ')))
def prino(colour, numsvet):
print('Светофор номер {} зажегся {} цветом'.format(numsvet, colour))
def svetofor(col, numsv):
por1[numsv] = por.replace(str(col), '')
for i in por1[numsv]:
prino(pora[i], numsv)
while True:
for i in por:
prino(pora[i], numsv)
def svets(num):
for i in range(int(num)):
Thread(target=svetofor, args=(i+1, i,)).start()
svets(numsv)
prino(pora[i], numsv)
KeyError: '2'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question