Can't promise you I didn't make any mistakes here, but something to think about in terms of reducing a lot of that redundant code:
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import time import cursor import colorama as cr COLUMN_POSITIONS = (5, 8, 13, 16, 21, 24) def get_cursor_locations(column): locations = {2**i : cr.Cursor.POS(column, 11-2*i) for i in range(5)} locations[0] = cr.Cursor.POS(column, 13) return locations def render(display, digit, cursors): binary = bin(int(digit))[:1:-1] if not any(int(bit) for bit in binary): print("{}{}{}".format(display, cursors[0], 0)) else: for i,bit in enumerate(binary): if int(bit): print("{}{}{}".format(display, cursors[2**i], 2**i)) def main(): cursor.hide() try: for c in range(60): # Currently set for 1 min. (1 hr = 3600, 24 hrs = 86400) os.system('cls' if os.name == 'nt' else 'clear') # Get current time: hours (24 hour clock), minutes, seconds) and put in a list t_now = [time.strftime("%H"), time.strftime("%M"), time.strftime("%S")] str_t = "".join(t_now) # Initialize and set some colors for colorama cr.init() off = cr.Back.BLACK on = cr.Fore.RED # Print Header tab = " " * 4 print(off) print(on + tab + 'HRS' + tab + ' MIN' + tab + ' SEC' + "\n") # Run clock display = cr.Fore.RED for digit, column in zip(str_t, COLUMN_POSITIONS): render(display, digit, get_cursor_locations(column)) time.sleep(1) except KeyboardInterrupt: print("\n" * 8) print("Program stopped") print(cr.deinit()) cursor.show() # Show cursor again exit(0) print("\n" * 8) print(cr.deinit()) cursor.show() # Show cursor again if __name__ == "__main__": main()