My goal: I am trying to get the user to type in their own query for a troubleshooting system. If the user's input has a keyword that is found in the 'keywords' array, a solution is given from the same index in the 'answers' array.
The problem: There are no syntax errors but a logic error. For the first and second index in the 'keywords' array, if this keyword is inputted then a correct solution is given. However, for the third and fourth index in the 'keywords' array, it outputs the wrong solution from a different index in the 'answers' array.
My code:
answers = ['dry it out','replace screen','delete any apps that are not needed','restart it']
keywords = ['wet','cracked','download','unresponsive']
i = 0
while i <= 5:
user_query = str(input('What\'s the problem?\n>> ')).lower()
for keyword in keywords:
while keyword[i] not in user_query:
i = i + 1
if keyword[i] in user_query:
print(answers[i])
i = 10
break
if i >= 5:
print('contact the supplier')
break