Python random answering program
Question: I wrote this programm

    
    
    #!/usr/bin/env python
    """
    """
    import random
    def CollectStrings():
       string_list = []
       while True:
          string = raw_input("What is your question: (enter to quit): ")
          if not string:
             return string_list
          string_list.append(string)
    
    def ChooseStrings(how_many):
      string_list = CollectStrings()
      chosen = random.sample(string_list, how_many)
      chosen.sort()
      return ', '.join(chosen)
    
    print ChooseStrings (3)
    

But I need to make this program randomly answer questions, like an 8ball. How
would I do that?


Answer: Add all answers to a list and than use
[random.choices](http://docs.python.org/library/random.html#random.choice) to
get a random answer:

    
    
    import random
    
    answers = [
        "The answer lies in your heart",
        "I do not know",
        "Almost certainly",
        "No",
        "Yes",
        "Why do you need to ask?",
        "Go away. I do not wish to answer at this time.",
        "Time will only tell",
    ]
    print random.choice(answers) // Print random answer
    

