-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnakes.py
38 lines (28 loc) · 855 Bytes
/
snakes.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
from termcolor import colored
class Snake:
def __init__(self, head, tail):
self.head = head
self.tail = tail
heads = [17, 54, 62, 64, 87, 93, 95, 99]
tails = [7, 34, 19, 60, 24, 73, 75, 78]
snakes = []
for i in range(len(heads)):
snake = Snake(heads[i], tails[i])
snakes.append(snake)
def snake_check(position):
ini_pos = position
for snake in snakes:
if snake.head == position:
position = snake.tail
else:
pass
if ini_pos != position:
print(colored("""Busted! Python bite
Don't Worry! Alice saved you. But your position changed.""", 'red'))
else:
print("No python")
return position
def snake_list():
print("Pythons : ")
for snake in snakes:
print(f'\t(Head : {snake.head}, Tail : {snake.tail})')