Dictionary to respond to a question (python)
rediar (134)

How would I use a dictionary to detect if someone said something, and respond?

You are viewing a single comment. View All
CaptainAnon (52)
question2answer = {
  # Fill this in with question and answer combinations
  'question': 'answer'
}
question = input("What is your question? ")
if question in question2answer:
  print(question2answer['question'])
else:
  print("I'm not sure how to respond to that question.")

If you're happy to not use dictionaries you could also try using a neural network to do this (probably a recurrent neural network)!

rediar (134)

@CaptainAnon neural networks are way too much work. let me test this out.