Package: input-timeout
input_timeoutDefine how long you want to wait for the user's input.After the time is over, a default value is set.Install it:pipinstallinput-timeoutUse it:frominput_timeoutimportInputTimeouti=InputTimeout(timeout=20,input_message=" >> ",timeout_message="'Sorry, you were not fast enough'",defaultvalue="slow",cancelbutton="esc",show_special_characters_warning='If you want to use special characters, you have to use alt+\\d\\d\\d\\d\nPress "ctrl" to see a complete list of all combinations!',).finalvalueprint(f"\n\nYour input was{i}")i=InputTimeout(timeout=5,input_message=" >> ",timeout_message="Sorry, you were not fast enough: ",defaultvalue="slow",cancelbutton="esc",show_special_characters_warning='If you want to use special characters, you have to use alt+\\d\\d\\d\\d\nPress "ctrl" to see a complete list of all combinations!',).finalvalueprint(f"\n\nYour input was{i}")i=InputTimeout(timeout=10,input_message=" >> ",timeout_message="Sorry, you were not fast enough",defaultvalue="Wake up!",cancelbutton=None,show_special_characters_warning=None,).finalvalueprint(f"\n\nYour input was{i}")i=InputTimeout(timeout=10,input_message=" >> ",timeout_message="Sorry, you were not fast enough",defaultvalue="Are you sleeping?",cancelbutton="esc",show_special_characters_warning=None,).finalvalueprint(f"\n\nYour input was{i}")i=InputTimeout(timeout=10,input_message=" >>",timeout_message="Sorry, you were not fast enough",defaultvalue="you are so slow",cancelbutton=None,show_special_characters_warning='If you want to use special characters, you have to use alt+\\d\\d\\d\\d\nPress "ctrl" to see a complete list of all combinations!',).finalvalueprint(f"\n\nYour input was{i}")Output:#outputIfyouwanttousespecialcharacters,youhavetousealt+\d\d\d\dPress"ctrl"toseeacompletelistofallcombinations!>>babbaYourinputwasbabbaIfyouwanttousespecialcharacters,youhavetousealt+\d\d\d\dPress"ctrl"toseeacompletelistofallcombinations!alt+0192->Àalt+0193->Áalt+0196->Äalt+0194->Âalt+0195->Ãalt+0197->Åalt+0198->Æalt+0228->äalt+0224->àalt+0225->áalt+0226->âalt+0227->ãalt+0229->åalt+0230->æalt+0199->Çalt+0231->çalt+0208->Ðalt+0240->ðalt+0203->Ëalt+0200->Èalt+0201->Éalt+0202->Êalt+0235->ëalt+0232->èalt+0233->éalt+0234->êalt+0207->Ïalt+0204->Ìalt+0205->Íalt+0206->Îalt+0239->ïalt+0236->ìalt+0237->íalt+0238->îalt+0209->Ñalt+0241->ñalt+0214->Öalt+0210->Òalt+0211->Óalt+0212->Ôalt+0213->Õalt+0216->Øalt+0140->Œalt+0246->öalt+0242->òalt+0243->óalt+0244->ôalt+0245->õalt+0248->øalt+0156->œalt+0138->Šalt+0223->ßalt+0154->šalt+0222->Þalt+0254->þalt+0220->Üalt+0217->Ùalt+0218->Úalt+0219->Ûalt+0252->üalt+0249->ùalt+0250->úalt+0251->ûalt+0159->Ÿalt+0221->Ýalt+0255->ÿalt+0253->ýalt+0168->¨alt+0136->ˆalt+0180->´alt+0175->¯alt+0184->¸alt+0192->Àalt+0193->Áalt+0196->Äalt+0194->Âalt+0195->Ãalt+0197->Åalt+0198->Æalt+0228->äalt+0224->àalt+0225->áalt+0226->âalt+0227->ãalt+0229->åalt+0230->æalt+0199->Çalt+0231->çalt+0208->Ðalt+0240->ðalt+0203->Ëalt+0200->Èalt+0201->Éalt+0202->Êalt+0235->ëalt+0232->èalt+0233->éalt+0234->êalt+0207->Ïalt+0204->Ìalt+0205->Íalt+0206->Îalt+0239->ïalt+0236->ìalt+0237->íalt+0238->îalt+0209->Ñalt+0241->ñalt+0214->Öalt+0210->Òalt+0211->Óalt+0212->Ôalt+0213->Õalt+0216->Øalt+0140->Œalt+0246->öalt+0242->òalt+0243->óalt+0244->ôalt+0245->õalt+0248->øalt+0156->œalt+0138->Šalt+0223->ßalt+0154->šalt+0222->Þalt+0254->þalt+0220->Üalt+0217->Ùalt+0218->Úalt+0219->Ûalt+0252->üalt+0249->ùalt+0250->úalt+0251->ûalt+0159->Ÿalt+0221->Ýalt+0255->ÿalt+0253->ýalt+0168->¨alt+0136->ˆalt+0180->´alt+0175->¯alt+0184->¸Sorry,youwerenotfastenough:Yourinputwasslow>>superYourinputwassuper>>adasaYourinputwasadasaIfyouwanttousespecialcharacters,youhavetousealt+\d\d\d\dPress"ctrl"toseeacompletelistofallcombinations!Sorry,youwerenotfastenoughYourinputwasyouaresoslow