from PyInquirer import prompt widget = [ { 'type':'input', 'name':'myVar', 'message':'Your integer data please :', 'filter':lambda val: int(val) } ] try : result = prompt(widget) except ValueError : print('Integer required !!!') exit() print('Your answer is') print(result["myVar"]) print(type(result["myVar"]))