timeout= limit= if the user answers after the -second timeout has expiredeven if they answer correctlypyip inputstr(raises timeoutexception exception if the user answers incorrectly more than timesit raises retrylimitexception exception both of these exception types are in the pyinputplus moduleso pyip needs to prepend themexcept pyip timeoutexceptionprint('out of time!'except pyip retrylimitexceptionprint('out of tries!'remember thatjust like how else blocks can follow an if or elif blockthey can optionally follow the last except block the code inside the following else block will run if no exception was raised in the try block in our casethat means the code runs if the user entered the correct answerelsethis block runs if no exceptions were raised in the try block print('correct!'correctanswers + no matter which of the three messages"out of time!""out of tries!"or "correct!"displayslet' place -second pause at the end of the for loop to give the user time to read it after the program has asked questions and the for loop continueslet' show the user how many correct answers they madetime sleep( brief pause to let user see the result print('score% % (correctanswersnumberofquestions)pyinputplus is flexible enough that you can use it in wide variety of programs that take keyboard input from the useras demonstrated by the programs in this summary it' easy to forget to write input validation codebut without ityour programs will almost certainly have bugs the values you expect users to enter and the values they actually enter can be completely differentand your programs need to be robust enough to handle these exceptional cases you can use regular expressions to create your own input validation codebut for common casesit' easier to use an existing modulesuch as pyinputplus you can import the module with import pyinputplus as pyip so that you can enter shorter name when calling the module' functions pyinputplus has functions for entering variety of inputincluding stringsnumbersdatesyes/notrue/falseemailsand files while input(input validation