I'm a beginner at python. I want the user to input a problem and then the program should pick out words and read the file accordingly. For example, if they used the word 'water' then it will read the appropriate line and print it. At the moment it only works if that key word is at the end out the inputted string.
screen = ["display", "screen", "broken", "glass", "cracked"]
software = ["frozen", "stuck", "weird", "flashing" , "virus" , "reboot" ,"loop"]
body = ["broken" , "dented" , "dropped" , "smashed"]
water = ["wet" , "water" , "rain" , "damage" , "damaged" , "toilet" , "damp"]
heat = ["overheating" , "hot" , "burning" , "burn" , "warm"]
problem = input("Please tell me what is wrong with your phone! ") #this is to break up the users input so the words can be found seperately in the list
for j in problem.split():
pass
if j in screen:
solution = open("sfs.txt","r")
solutionread = solution.readline()
solution.close()
print(solutionread)
The rest of the code uses the if elif else code. It also uses readline to read the line I need. I am not very experienced and still learning so please try give me simple answers as too making it work effectively. Thanks!