Oct-17-2019, 03:29 PM
The program I'm currently working on asks the user to press SPACE if correct or ENTER if incorrect. Can you give me a code snippet that will enable Python to recognize this? I started with this:
The problem is that in order to recognize a space or enter, the enter key has to be subsequently pressed. This makes for two keystrokes when I really want one due to time constraints.
1 2 3 4 5 6 7 8 |
checkif = True #this indicates whether I still need to check input for r in range (origlistsize): #this will be done origlistsize times (total # of problems in list) question = random.randint( 0 ,curlistsize) answer = input (multfacts[question]) while checkif = = True : if answer = = " " or answer==" ": checkif = False else : answer = input ( "Enter SPACE if that was correct or ENTER if wrong: " ) |