Advertisement
furas

Python - ask integer

May 22nd, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. while True:
  2.     text = input("> ")
  3.     try:
  4.         val = int(text)
  5.         break # it will execute only if there was no exception
  6.     except ValueError:
  7.         print("It is not integer value")
  8.  
  9. print("val =", val)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement