File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 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
1919import random
2020import time
2121
22- print ("Welcome to the Magic 8 Ball!" )
2322
2423responses = ["Yes, most definitely!"
2524, "The chances are high!"
@@ -38,15 +37,17 @@ def userquestion():
3837print ("\n Thinking...\n " )
3938time .sleep (random .randrange (0 ,5 ))
4039print (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 ("\n Thank 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 ("\n Thank you for playing!" )
48+ break
49+
50+ if __name__ == '__main__' : main ()
5051
5152
5253
You can’t perform that action at this time.
0 commit comments