Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sage program question
#1
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..
#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()
Reply


Messages In This Thread
Sage program question - by Doesnotcompute - Oct-21-2016, 09:45 AM
RE: Sage program question - by sparkz_alot - Oct-21-2016, 03:15 PM
RE: Sage program question - by nilamo - Oct-24-2016, 05:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Basic Coding Question: Exit Program Command? RockBlok 3 629 Nov-19-2023, 06:31 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020