I am having trouble with this trivia program. I have to be able to read the questions and answers from a text file using a while loop. I then have to ask the user what the answer is and tell them if they are correct or not. Then I have to tell them how many answers they got correct. Last, I have to ask them if they wish to run it again.
My problem is when I run the while loop it runs past the 20th question in the text file. My code is below, if you could help me that would be great.
print('Welcome to The Computer Trivia Program!')
F=open('Culminating Project Trivia Questions.txt','r')
AC=0
while F!='':
Q=F.readline()
print(Q)
C1=F.readline()
print(C1)
C2=F.readline()
print(C2)
C3=F.readline()
print(C3)
C4=F.readline()
print(C4)
A=input('Enter an Anwser:')
ANS=F.readline()
print(ANS)
if A==ANS[14]:
print('Correct')
AC=AC+1
elif A!=ANS[14]:
print('Incorrect')
AC=AC
if F=='':
break
F.close()
print('Your Total Amount of Correct Answers out of 20 is:',AC)
print('Thankyou for Playing Computer Trivia!')