-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzigzag.py
More file actions
29 lines (23 loc) · 788 Bytes
/
zigzag.py
File metadata and controls
29 lines (23 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# zigzag.py
# Prints a continuous zigzag to the console.
import sys
import time
indent = 0 # Number of spaces to indent.
indent_increasing = True # Whether indent is increasing or not.
max_indent = 25 # Set level of zag
try:
# Main Loop
while True:
print(' ' * indent, end='')
print('*****')
time.sleep(0.1) # Pause for 1/10 of a second.
if indent_increasing:
indent += 1
if (indent == max_indent):
indent_increasing = False # Change direction
else:
indent -= 1 # Decrease the number of spaces.
if (indent == 0): # Change direction
indent_increasing = True
except KeyboardInterrupt:
sys.exit()