-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchristmas_tree.py
40 lines (36 loc) · 1.09 KB
/
christmas_tree.py
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
30
31
32
33
34
35
36
37
38
39
40
import os
import time
from itertools import cycle
import random
def blinking_tree():
tree = [
" * ",
" *** ",
" ***** ",
" ******* ",
" ********* ",
" *********** ",
" ************* ",
" ||| ",
" ",
" ",
" ",
" .less ",
]
lights = cycle(["\033[91m*\033[0m", "\033[93m*\033[0m", "\033[92m*\033[0m", "\033[94m*\033[0m", "\033[95m*\033[0m"])
reset = "\033[0m"
try:
while True:
os.system("clear")
for i, line in enumerate(tree):
if i in range(1, 7):
line = ''.join(
next(lights) if char == '*' and random.choice([True, False]) else char
for char in line
)
print(line)
time.sleep(0.5)
except KeyboardInterrupt:
print("\nMerry Christmas! 🎄 by .less")
if __name__ == "__main__":
blinking_tree()