Oct-21-2016, 09:45 AM
Hi , I have a problem with the following code (it's fairly simple I guess) , when I enter "what is love?" I get one of the random responses back , and before I managed to let it do this, I got a random response + the intended response to this question(because I made a questionmark the (I have no idea what it is called)).
How can I let python check for the intended input in a practical manner?
Sorry for the strange way of asking this question , I'm new and don't yet know all the names..
How can I let python check for the intended input in a practical manner?
Sorry for the strange way of asking this question , I'm new and don't yet know all the names..
#Sage Program opening = print("Greetings! I am the mighty sage , capable of answering all of your questions!") opening def sageprogram(): questionmark = """?""" haddaway = """What is love?""" question = input("What is your question? : ") print("You ask me : ",question) answers = ["You know the answer to that already , don't you?", "I would focus my thoughts on something else...", "The probabilities are in your favor!", "It is close to certainty.", "Someone you would not expect can be most helpful about this.", "Baby don't hurt me! don't hurt me! no more!"] def AskQuestionAgain(): question2 = input("\nWould you like to ask another question to the mighty sage?(yes/no) : ") if "yes" in question2: sageprogram() elif "no" in question2: print("Ok, bye.") input('\n') else: print("Only answer in yes or no , please.") AskQuestionAgain() AskQuestionAgain() import random if questionmark in question: print(random.choice(answers[:4])) AskQuestionAgain() if haddaway in question: print (answers[5]) AskQuestionAgain else: print("I am a sage who can only read questions! ASK AGAIN!") sageprogram() sageprogram()