-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMantainADogThroughCoding.py
37 lines (36 loc) · 1.02 KB
/
MantainADogThroughCoding.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
import sys
# commands: woof, bark, argh, rrrr, yawn, barf, howl, ruff, umph
file = open(sys.argv[1],"r")
cookies = 1
stack = []
for line in file:
if "woof" in line:
cookies += 1
if line.startswith("bark"):
reverse_number=str(line.replace("bark","").strip())[::-1]
stack.insert(0,int(reverse_number))
cookies-=1
if "argh" in line:
stack.reverse()
cookies-=1
if "rrrr" in line:
print(chr(stack[0]),end='')
cookies-=1
if "ruff" in line:
print(stack[0],end='')
cookies-=1
if "yawn" in line:
stack.pop(0)
cookies-=1
if "barf" in line:
stack.insert(0,int(input()))
if "howl" in line:
stack.insert(0,stack[0])
if cookies <= 0:
print("the dog won't answer you, no cookies, no program")
break
if "umph" in line:
if len(stack) > 0:
print("Your dog's exausted! Too much informations to remeber")
else:
break