-
Notifications
You must be signed in to change notification settings - Fork 12.5k
/
Copy pathmagic8ball.py
51 lines (45 loc) · 1.17 KB
/
magic8ball.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
41
42
43
44
45
46
47
48
49
50
51
from time import sleep
from random import randint
from colorama import Fore, Style
response = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes, definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Yes",
"Signs point to yes",
"Quite possibly so",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful"]
def game():
ques = str(input("What is your question? \n").lower())
print ("thinking...")
sleep(1)
idx = randint(0,20)
if idx <10: color = Fore.GREEN
elif idx>=10 and idx<15: color = Fore.YELLOW
else: color = Fore.RED
print (color+response[idx]+Style.RESET_ALL+'\n\n')
playloop()
def playloop():
ques_again = str(input("Would you like to ask another question? (y/n)\n").lower())
if ques_again == 'y':
game()
elif ques_again == 'n':
print("Auf Wiedersehen!")
else:
print ("What was that?/n")
playloop()
if __name__=='__main__':
game()