Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to cancel a input in python

def timed_input(seconds, print_if_failed, prompt, what_to_type):

    timer = Timer(seconds, print, [print_if_failed])
    timer.start()
    print(prompt)
    answer = input()
    if answer.lower() == what_to_type.lower() and timer.is_alive():
        timer.cancel()
        return True
    else:
        return False
 
PREVIOUS NEXT
Tagged: #cancel #input #python
ADD COMMENT
Topic
Name
6+6 =