이 코드는 작동하지만 텍스트 파일에서 두 가지 솔루션을 인쇄하고 싶습니다. 문제는 텍스트 파일에 두 줄을 인쇄하려고 할 때입니다. 키워드를 if 'word' == something then print
과 함께 사용하면 두 줄을 인쇄하고 싶습니다. 어떤 도움을 주시면 감사하겠습니다. 나는 여러 가지 다른 것들을 시도했다.두 가지 솔루션을 추가하는 방법
problem = False
while problem == False:
foo = open("solutions.txt","r")
print("What is wrong with your 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
코드를 텍스트로 게시하십시오! –
https://stackoverflow.com/help/mcve – khajvah
나는 당신이 무엇을 찾고 있는지 잘 모르겠습니다. 구체적인 예를 들려 줄 수 있습니까? 문제가 '분쇄'된 경우 해결책 [3]을 인쇄하거나 해결책 [3]을 인쇄하고 싶습니까? 예를 들어? –