Python Program to Create a Countdown Timer – 2022

Machine Learning Projects

Hey guys, in this blog we will see a Python Program to Create a Countdown Timer.

Countdown time in Python

import time

def countdown(time_sec):
    while time_sec:
        mins, secs = divmod(time_sec, 60)
        timeformat = '{:02d}:{:02d}'.format(mins, secs)
        print(timeformat, end='\r')
        time.sleep(1)
        time_sec -= 1

    print("stop")

countdown(5)
  • This will create a counter in python which will count backward from 5 to 0.

00:05
00:04
00:03
00:02
00:01

Check out our other python programming examples

Leave a Comment

Your email address will not be published. Required fields are marked *