# Import the randint function from random library
from random import randint
# Import the sleep function from time library
from time import sleep
# Import clear screen function from IPython.display library
from IPython.display import clear_output
# List containing all possible respones. A random item will be choosen from this list
responses = ["As I see it, yes.", "Ask again later.", "Better not tell you now.", "Cannot predict now.",
"Concentrate and ask again.", "Don’t count on it.", "It is certain.", "It is decidedly so.",
"Most likely.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Outlook good.",
"Reply hazy, try again.", "Signs point to yes.", "Very doubtful.", "Without a doubt.",
"Yes.", "Yes - definitely.", "You may rely on it."]
# Replay Prompt function that will take a Y or N input and determine if user watne
def replay_prompt():
# Get user input which should be a y or no and then put's it in lowercase just in case it's not already
user_answer = input("Would you like to go again. [Y, N]: ").lower()
# Does a if else on the user_answer, if it's y it will return True, it it's n return False and neither
# Rerun the function, to get a valid input
if user_answer == 'y':
return True
elif user_answer == 'n':
print("Alright then I suppose, thanks for checking us out. Come back anytime")
return False
else:
replay_prompt()
while True:
# Generates a random number in which will later be used to get random item from the resonse list
response_index = randint(1, 19)
# Gets the user question, input is not required though
user_question = input("What would you question be, oh by the way we might know you more than you know yourself: ")
# If the user question is empty, print a message saying the system already knows the answer
if user_question == "":
print("Oh, so it looks like you rather not say. Well anyways here is your answer")
# Sleep for a random amount of time between 1 and 7 seconds
print("\nGenerating answer, to your special or secret question...")
delay_amount = randint(2, 7)
sleep(delay_amount)
# Print a message which depends if the question empty or not and then print the answer
if user_question == "":
print("\nThe answer to your secret question is: ")
else:
print("\n{}".format(user_question))
print(responses[response_index])
# Invoke the replay_prompt function, if the return value is True, run the loop again if not break from it
if replay_prompt() is True:
continue
else:
break