python - How to add two solutions -


so code works, want print 2 solutions off text-file. problem includes trying print out 2 lines in text file, when keywords used if 'word' == print, want print 2 lines. appreciated. have tried various different things.

problem = false  while problem == false:      foo = open("solutions.txt","r")      print("what wrong device?")      issue=input()      if (('wet' in issue) or ('water' in issue)):         solutions = foo.readlines()         print(solutions[0])         problem = true      if (('cracked' in issue) or ('dropped' in issue)):         solutions = foo.readlines()         print(solutions[1])         problem = true 

if solutions fixed, should move file opening , reading outside loop. match between keywords , solution index can done dictionary.

problem = false  foo = open("solutions.txt","r") solutions = foo.readlines()  problemlistdict = {'wet':0, 'water':0, 'dropped':1, 'sim card':2} #etc..etc  while problem == false:      print("what wrong device?")      issue=input()      sol = set()      k in problemlistdict.keys():         if k in issue:             sol.add(problemlistdict[k]) 

the result set sol containing index relevant solution lines.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -