-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmagic8.py
More file actions
33 lines (26 loc) · 815 Bytes
/
magic8.py
File metadata and controls
33 lines (26 loc) · 815 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
30
31
32
33
import random
responses = [
"Yes, definitely.",
"As I see it, yes.",
"Reply hazy, try again.",
"Cannot predict now.",
"Do not count on it.",
"My sources say no.",
"Outlook not so good.",
"Very doubtful."
]
def magic_8_ball():
print("Welcome to the Magic 8 Ball! Ask a yes/no question.")
while True:
question = input("Ask your question (or type 'quit' to exit): ")
if question.lower() == 'quit':
print("Thanks for playing! Goodbye!")
break
if question.strip() == "":
print("Please ask a valid question.")
continue
# Get a random response
answer = random.choice(responses)
print("Magic 8 Ball says:", answer)
# Run the program
magic_8_ball()