0
import time
listy = ['timer','stopwatch']

def intro():
    print("This is a program which contains useful tools")
    print(listy)

def timer():
    x = int(input("How long Seconds ?"))
    while x > 0:
        print(x)
        time.sleep(1)
        x -= 1

def stopwatch():
    verif = input("Do you want to start y/n \n")
    if verif == 'y':
        x = 0
        while True:
            print(x, end = "\b"*5)
            time.sleep(1)
            x += 1

def main():
    intro()
    decider = input("Which Program?")
    if decider.lower() == 'timer':
        timer()
    elif decider.lower() == 'stopwatch':
        stopwatch()

main()

in this code i dont know why the \b escape sequence isnt working in cmd or in idle, can anyone explain why? Is it because of a logic error?

VOID
  • 1
  • 1

1 Answers1

0

A flush may be required. How about...

print("{0}{1}".format("\b"*5, x), end="", flush=True)
lit
  • 14,456
  • 10
  • 65
  • 119