Within an IF statement, I have a string and wish to compare it with a text file. Currently I have the following:
#The part of the program that checks the user’s list of words against the external file solved.txt and displays an appropriate ‘success’ or ‘fail’ message.
if ''.join(open('test.txt').read().split('\n')):
print('Success')
else:
print('Fail')
print()
#If the puzzle has not been completed correctly, the user should be allowed to continue to try to solve the puzzle or exit the program.
continue_or_exit = input('Would you like to "continue" or "exit"? ')
if continue_or_exit == 'continue':
task3(word_lines, clueslistl, clueslists, clues)
elif continue_or_exit == 'exit':
quit()
else:
print()
However, this does not work. Even if the string and the text file are exactly the same, the command prompt will always print 'Fail'.
solved.txt:
ACQUIRED
ALMANAC
INSULT
JOKE
HYMN
GAZELLE
AMAZON
EYEBROWS
AFFIX
VELLUM
textandtext.txt? What isstr(if not the builtin type)?