0
I’m trying to make a program in Python that during the execution of a loop, some command is waiting for an input condition while the loop is executed.
For example, a program that prints numbers in ascending order and 1 in 1 second from zero while waiting for the user to type a string "terminates". When such a string is read, the loop is stopped and stops printing the numbers on the screen.
I tried to do it like this, but it didn’t work:
#-*- coding: utf-8 -*-
import time
i = 0
mensagem = 0
while mensagem!='terminar':
mensagem = str(raw_input())
if mensagem=='terminar':
print "encerrado"
else:
print i
time.sleep(1)
i+=1
Reading and writing on the console at the same time is hardly a good idea. Better you create a graphical interface as suggested by nosklo.
– Gabriel