Skip to content

Commit 694143e

Browse files
committed
Amend Magic8Ball
1 parent e48b1c5 commit 694143e

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

Magic8Ball.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@
99
# Add a gui.
1010
# It must have box for users to enter the question.
1111
# It must have at least 4 buttons:
12-
# ask
13-
# clear (the text box)
14-
# play again
15-
# quit (this must close the window)
12+
#ask
13+
#clear (the text box)
14+
#play again
15+
#quit (this must close the window)
1616
# TODO: finish GUI
1717

1818

1919
import random
2020
import time
2121

22-
print("Welcome to the Magic 8 Ball!")
2322

2423
responses = ["Yes, most definitely!"
2524
, "The chances are high!"
@@ -38,15 +37,17 @@ def userquestion():
3837
print("\nThinking...\n")
3938
time.sleep(random.randrange(0,5))
4039
print(random.choice(responses))
41-
42-
while True:
43-
userquestion()
44-
repeat = input("Would you like to ask another question? (y/n)")
45-
if not (repeat == "y" or repeat == "Y"):
46-
print("\nThank you for playing!")
47-
break
48-
4940

41+
def main():
42+
print("Welcome to the Magic 8 Ball!")
43+
while True:
44+
userquestion()
45+
repeat = input("Would you like to ask another question? (y/n)")
46+
if not (repeat == "y" or repeat == "Y"):
47+
print("\nThank you for playing!")
48+
break
49+
50+
if __name__ == '__main__': main()
5051

5152

5253

0 commit comments

Comments
 (0)