Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. def interact():
  2. while True:
  3. try:
  4. user_input = int(input('Please input an integer:'))
  5. except ValueError:
  6. print('Please input only intergers')
  7. raise
  8. else:
  9. print('{} is {}.'.format(user_input, 'even' if user_input % 2 == 0 else 'odd'))
  10. finally:
  11. user_input = input('Do you want to play again? (y/N):')
  12. if user_input != 'y':
  13. print('Goodbye.')
  14. break
  15.  
  16. interact()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement