I am trying to make a sort of quiz revision code for my exams. I am however struggling to get the selection for whether the answer is right or not to work. no matter what answer I put it outputs "nope". Each file I use has 6 lines. import random
file = open("questions.txt", "r")
questions = file.readlines()
file2 = open("answers.txt", "r")
answers = file2.readlines()
question_answering = True
while question_answering:
question = random.randrange(5)
print(questions[question])
answer = input("enter your answer: ")
print(answers[question])
if answer == answers[question]:
print("well done!")
else:
print("nope")
I have included a test which is print(answers[question])
which does output the correct answer that I am looking for but when I input that answer it does not work.