Library keyboard applied within a for loop

0

I have a code with a loop. Within this loop that is running, I need to make the option that each time I press the letter O, a certain value x (previously defined by me in tbus ) is added to a given account in this loop for only one (the account then happens again without this addition, returning it only when O is pressed again). How do I get this? In the template that is, it does not work and I can not fix it

import keyboard 

tbus    = input ('Insira o tempo do  onibus:\n')   
sem_1_2 = input ('Insira o tempo do sinal 1 e 2:\n')


for i in range(100):
    sem_1_2_3 = 9 # valor normal da variável, sem acréscimo devido pressionar tecla 'o'
    try:      
        while True:          
            try: 
                if keyboard.is_pressed('o'):
                    sem_1_2_3 = sem_1_2 + tbus # adição do valor 'tbus'caso se pressione 'o'
                    break
                else:
                    pass
            except:
                break  
    
asked by anonymous 21.11.2018 / 01:54

0 answers