From e8795ad0c7474e6f8e09f88513a35028ceb07034 Mon Sep 17 00:00:00 2001 From: Eklavya Chandra <70642430+EklavyaChandra@users.noreply.github.com> Date: Sun, 4 Oct 2020 13:56:49 +0530 Subject: [PATCH] Add files via upload You should make these changes. It's important --- 8balls-magic.py | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/8balls-magic.py b/8balls-magic.py index 956c2cc..17fb1b0 100644 --- a/8balls-magic.py +++ b/8balls-magic.py @@ -2,36 +2,20 @@ import sys import random #how to improve such if else logic with contineous QA? -ans = True - -while ans: - question = raw_input("Ask the magic 8 ball a question: (press enter to quit) ") - - answers = random.randint(1,8) - +#Answer = You Can add while True statement +# You doesnot need to create a boolean for this one +answers = random.randint(1,8) # Here I have put this not in while loop because it will generate a random number everytime. +# print(answers) +while True: + question = int(input("Ask the magic 8 ball a question: (Enter to quit) ")) if question == "": sys.exit() - - elif answers == 1: - print "It is certain" - - elif answers == 2: - print "Outlook good" - - elif answers == 3: - print "You may rely on it" - - elif answers == 4: - print "Ask again later" - - elif answers == 5: - print "Concentrate and ask again" - - elif answers == 6: - print "Reply hazy, try again" - - elif answers == 7: - print "My reply is no" - - elif answers == 8: - print "My sources say no" + # Here I have put question bcoz the number that the user enters will be put in the variable(question). You can do better. + elif answers == question: + print("Nice, you r correct") + answers = random.randint(1,8) + # print(answers) + # Always Remember to typecast the numbers in int not in string........I have worked in your project. Plz save it.Thanks + # From India + else: + print("your incorrect")