Hi everyone,
I hope it’s ok if I ask this here.
I am brand new at computer programming, but I am taking an online class in python and need help with an assignment. I sent an email to my instructor but have not heard back and I would appreciate it if someone here could help.
I am building a 8 ball program that returns a random answer from one of 20 answers. It needs to say goodbye and end program if the user enters the words exit or bye.
I have it working fine except for one problem. If you type the word exit it says goodbye but doesn’t close.
I have tried everything I can think of. What am I doing wrong? Here is the code I wrote.
while input("What is your question? ") != 'exit':
r = answers[random.randint(0, 19)]
print(r)
else:
print("Goodbye")
if input("What is your question? ") == 'bye':
print("Goodbye")
else:
print(r)
Thanks for any suggestions you can give me.