File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Python_Begginer_Projects/Easy Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ import random
2
+
3
+ responses = [
4
+ "Yes, definitely." ,
5
+ "As I see it, yes." ,
6
+ "Reply hazy, try again." ,
7
+ "Cannot predict now." ,
8
+ "Do not count on it." ,
9
+ "My sources say no." ,
10
+ "Outlook not so good." ,
11
+ "Very doubtful."
12
+ ]
13
+
14
+ def magic_8_ball ():
15
+ print ("Welcome to the Magic 8 Ball! Ask a yes/no question." )
16
+
17
+ while True :
18
+ question = input ("Ask your question (or type 'quit' to exit): " )
19
+
20
+ if question .lower () == 'quit' :
21
+ print ("Thanks for playing! Goodbye!" )
22
+ break
23
+
24
+ if question .strip () == "" :
25
+ print ("Please ask a valid question." )
26
+ continue
27
+
28
+ # Get a random response
29
+ answer = random .choice (responses )
30
+ print ("Magic 8 Ball says:" , answer )
31
+
32
+ # Run the program
33
+ magic_8_ball ()
You can’t perform that action at this time.
0 commit comments