Browse Source

Simple integer filter

Jovian (Netbook) 6 years ago
parent
commit
b97c43a127
1 changed files with 19 additions and 0 deletions
  1. 19 0
      text_question_filtered.py

+ 19 - 0
text_question_filtered.py

@@ -0,0 +1,19 @@
+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"]))