Advertisement
Guest User

zigzag

a guest
May 3rd, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. import time, sys
  2. indent = 0 # How many spaces to indent.
  3. indentIncreasing = True # Whether the indentation is increasing or not.
  4.  
  5. try:
  6.     while True: # The main program loop.
  7.         print(' ' * indent, end='')
  8.         print('********')
  9.         time.sleep(0.1) # Pause for 1/10 of a second.
  10.  
  11.         if indentIncreasing:
  12.             # Increase the number of spaces:
  13.             indent = indent + 1
  14.             if indent == 20:
  15.                 # Change direction:
  16.                 indentIncreasing = False
  17.  
  18.         else:
  19.             # Decrease the number of spaces:
  20.             indent = indent - 1
  21.             if indent == 0:
  22.                 # Change direction:
  23.                 indentIncreasing = True
  24.                
  25. except KeyboardInterrupt:
  26.     time.sleep(3.0)
  27.     sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement