I am new to python and creating a quiz program. I have the questions and answers to the quiz on separate text files.
The text file for answers are all in lower case so I don't believe that the .lower() is the problem.
Here is my following code:
#Programming exercise-Writing to files
question_file = open("Quiz.txt","r")
answer_file = open("QuizAnswers.txt","r")
print("Welcome to the ScienceQuiz!")
question = question_file.readlines()
answer = answer_file.readlines()
score = 0
i = 0
for i in range(20):
print(question[i])
user_input = input("Enter your answer: ")
user_input = user_input.lower()
if user_input == answer[i]:
score = score + 1
else:
score = score
print("\nYou scored: ",score,"/20")
At the end of the game even though all answers that I inputted were right it prints that I got 0/20?