Countdown from 2 minutes - how?

preved.rly at gmail.com preved.rly at gmail.com
Thu Mar 30 16:30:52 CEST 2006


#!/bin/env python
# countdown.py
import time
import doctest

def countdown( time_in_minutes):
    """
    >>> import countdown
    >>> countdown.countdown(0.1) # doctest:+ELLIPSIS
    6
    5
    ...
    1
    Time is up
    """
    for i in reversed(xrange(1, int(time_in_minutes * 60) + 1)):
        print i
        time.sleep(1)
    print 'Time is up'

if __name__=='__main__':
    doctest.testmod()




More information about the Python-list mailing list