I'm trying to write a program for multiplication facts. It generates the list of facts, randomizes it, and then goes through. I just enter y or n depending on whether the student gets it right or wrong.
I'm having problems with this part:
Is Line 6 of the code done correctly? My intent is to move past the while loop if either an "n" or "y" is passed. If the problem is correct ("y"), then, move onto the next problem. If incorrect then add to error list and move onto the next problem. Why is the latter not happening?
I'm having problems with this part:
for r in range(origlistsize): #this will be done origlistsize times (total # of problems in list) print(" Problem",r+1,"of",origlistsize,":",rndmultfacts[r]) print() print() answer = input(" Is answer right (y) or wrong (n)? ") while answer.lower() != ("y" or "n"): answer = input(" Is answer right (y) or wrong (n)? ") print(" top r =",r) #debug if answer.lower()=="y": print("middle r =",r) #debug continue else: print("bottom r =",r) #debug errlist1.append(rndmultfacts[r]) continueHere's some output:
Problem 1 of 16 : 3*2 = 6 Is answer right (y) or wrong (n)? h Is answer right (y) or wrong (n)? h top r = 0 Is answer right (y) or wrong (n)? h top r = 0 Is answer right (y) or wrong (n)? h top r = 0 Is answer right (y) or wrong (n)? h top r = 0 Is answer right (y) or wrong (n)? h top r = 0 Is answer right (y) or wrong (n)? h top r = 0 Is answer right (y) or wrong (n)? y top r = 0 middle r = 0 Problem 2 of 16 : 2*3 = 6 Is answer right (y) or wrong (n)? y middle r = 1 Problem 3 of 16 : 0*0 = 0 Is answer right (y) or wrong (n)? y middle r = 2 Problem 4 of 16 : 2*1 = 2 Is answer right (y) or wrong (n)? y middle r = 3 Problem 5 of 16 : 3*1 = 3 Is answer right (y) or wrong (n)? y middle r = 4 Problem 6 of 16 : 1*1 = 1 Is answer right (y) or wrong (n)? y middle r = 5 Problem 7 of 16 : 0*2 = 0 Is answer right (y) or wrong (n)? n Is answer right (y) or wrong (n)? n top r = 6 Is answer right (y) or wrong (n)? n top r = 6 Is answer right (y) or wrong (n)? n top r = 6 Is answer right (y) or wrong (n)?The y's and invalid entries seem to work, but the n's don't.
Is Line 6 of the code done correctly? My intent is to move past the while loop if either an "n" or "y" is passed. If the problem is correct ("y"), then, move onto the next problem. If incorrect then add to error list and move onto the next problem. Why is the latter not happening?