text_question_filtered.py 327 B

12345678910111213141516171819
  1. from PyInquirer import prompt
  2. widget = [
  3. {
  4. 'type':'input',
  5. 'name':'myVar',
  6. 'message':'Your integer data please :',
  7. 'filter':lambda val: int(val)
  8. }
  9. ]
  10. try :
  11. result = prompt(widget)
  12. except ValueError :
  13. print('Integer required !!!')
  14. exit()
  15. print('Your answer is')
  16. print(result["myVar"])
  17. print(type(result["myVar"]))