SHARE
TWEET

Python - get_integer()

furas Jun 2nd, 2018 (edited) 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def get_integer():
  2.     while True:
  3.         text = input('integer> ')
  4.         try:
  5.             value = int(text)
  6.         except ValueError as ex:
  7.             print('It is not integer:', text)
  8.         else:
  9.             return value
  10.  
  11. value = get_integer()
  12. if value is not None:
  13.     print("get integer:", value)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top