0

I'm writing a short code that asks the user if they would like to keep using the program. However, I'm stuck because everything I've tried isn't working. The program takes the first step of the if/else statement and runs with it no matter the input from the user. I've tried just having if/else statement, now I'm trying a while loop, and everything in between. Any help would be appreciated!

def main():
    response = True
    while response:
        print("Think of a question to ask the Magic 8 Ball and press enter.")
        input()
        randNumber = random.randint(1, 9)
        print(magicBall(randNumber))
        print()
        response = input("Press 'Y' if you have another question or 'N' if you want to quit: ")
        if response == "N" or "n":
            response = False
            print("Goodbye")
            break
            #sys.exit()
        else:
            main()
            sys.exit()
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • 1
    Don't use recursion for looping. Just let the loop repeat instead of calling `main()` again. – Barmar May 06 '21 at 16:07
  • remove the `else` part completely so you don't need to call `sys.exit` anywhere in your program. – Asocia May 06 '21 at 16:19

0 Answers0