Keyword Searching? HELP?

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

I have created ( and received help creating ) a program that will allow a user to answer questions and get a response that they need to fix their phone. This is meant to be a troubleshooting code. However, I want to adapt this to allow the code to ask the user a question, such as " Describe your issue" and then the system will pick out keywords that they have answered with. For example if they answered with, " the display and software is messing up" then the system would recognise the words " display" and " software". Any ideas on how I would do this?

Thanks, Peter :slight_smile:
<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

```python

questions = {“Device”: “What is your device\n”,#At the start of the code, questions will begin and in a random order asking what is wrong with the users phone.
“Display”: “Is your display working?\n”,
“Dropped”: “Has your device been dropped?\n”,
“Start”: “Is your device turning on?\n”,
“Update”: “Have you installed the lastst update on your device?\n”,
“Charge”: “Is your device having battery issues?\n”,
“Water”: “Has your device been exposed to water?\n”,
“Jailbreak”: “Is your device Jailbroken or Routed?\n”,
“Camera”: “Is your devices camera broken?\n”,
“Slow”: “Is your device slowing down?\n”

            }

#At this point the questions end and will start to display solutions to the problem that they have stated they have had.
responses = {“Device”: “Your device is %s.\n”,
“Display”: {“no”: “You entered no to display. \n”
"Try charging the phone for a couple hours and "
"let it charge, if this doesn’t work contact your "
“nearest supplier.\n”,
“yes”: None},
“Dropped”: {“yes”: “You entered Yes to the phone being dropped. If it is dented take it to your supplier.\n”,
“no”: None},

         "Start": {"no": "You entered the device isn't turning on. You may need to let the device charge for a couple hours, if this doesn't work, contact your nearest supplier.\n",
                  "yes": None},
         "Update": {"no": "You havent updated to the latest software on your device. Please do that soon to fix your issue.\n",
                  "yes": None},
         "Charge": {"yes": "You entered Yes to having battery issues, you may need a new battery for your device to make it work sufficiently. Best advice would be to let the battery die down and recharge it later.\n",
                  "no": None},
         "Water": {"yes": "You enetered you have exposed your device to water. A common solution for water damage is to leave it in rice over night. This will soak up any excess water in your device.\n",
                  "no": None},
         "Jailbreak": {"yes": "You have jailbroken/ routed your phone. This can commonly mess up operating systems. Please restore your device to factory settings.\n",
                  "no": None},
         "Camera": {"yes": "You have entered that your camera is not working. No common solutions for this issue. Please take it to the nearest supplier.\n",
                  "no": None},
         "Slow": {"yes": "You entered that your device is slowing down. Best advice would consist of deleting many useless things on the device and restore if that doesn't work.\n",
                  "no": None},
         
                }

def user_input(question, override=False):#This will help the user answer the questions if they type them in wrong.
“”"
Sanitize user input
:param question: Question to be asked
:param override: Override check for yes/no response
:return: response to question
“”"
while question:
try:
response = str(input(question))
if not override:
assert response in [‘yes’, ‘no’], “Please enter your answer in the format of [yes, no].\n”
question = False
return response
except AssertionError as error:
print(error)
def main():
“”"
Loops through all available questions and stores the response,
then loops through all answers and displays the corresponding information.
:return: None
“”"
answers = {
topic: user_input(question, override=True if topic in “Device” else False)#This demonstates Iteration as it loops overrides to help the user work the system.
for topic, question in questions.items()
}

for k, i in answers.items():
    if k is "Device":
        print(responses[k] % i)
    else:
        print(responses[k][i])

print("Thank you for using our service.")

main()

<do not remove the three backticks above>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.