I wish to make a program that will print numbers from 0
to x
, and simultaneously count time, and both execute simultaneously in console. How can I do that?
For example, I want to make program which will count time while the computer writes numbers from 0
to x
:
import time
import sys
time_counter = 0
number = int(input("NUMBER: "))
counter = 0
while (counter < number):
sys.stdout.write("NUMBERS: " + str(counter) + '\r')
counter += 1
sys.stdout.write('\n')
while (counter < number):
sys.stdout.write("TIME COUNTER: " + str(time_counter) + '\r')
time.sleep(1)
time_counter += 1
I want to these two while
code blocks to execute simultaneously.