def QandA():
s_easy = open("Science (Easy).txt","r")
score = 0
for x in range (5):
print(s_easy.readline())
answer = s_easy.readline()
useranswer = input("Enter your answer as an uppercase: ")
if useranswer.isspace()or useranswer.islower():
while useranswer.isspace() or useranswer.islower():
print("You must enter a valid letter.")
useranswer = input("Enter your answer as an uppercase: ")
while useranswer != "A" or useranswer != "B":
print("You must enter a valid letter.")
useranswer = input("Enter your answer as an uppercase: ")
if answer == useranswer:
score = score + 1
else:
score = score
elif answer == useranswer:
score = score + 1
else:
score = score
print(score)
I need the while loop to ask the user to input their answer again if the useranswer is not uppercase, a space or not "A" or "B". I also need the score to increase by increments of 1 with every correct answer and to be printed at the end. I have tried to include the score, but it is just not working for me.