Skip to content

Instantly share code, notes, and snippets.

@mIcHyAmRaNe
Created September 23, 2017 22:44
Show Gist options
  • Save mIcHyAmRaNe/89f7cb3d17595ee6746ffc3a03543070 to your computer and use it in GitHub Desktop.
Save mIcHyAmRaNe/89f7cb3d17595ee6746ffc3a03543070 to your computer and use it in GitHub Desktop.
python3: script that accept only integer and refuse 0 only accept even numbers for some odd reason. no pun intended
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
while True:
try:
x = int(input('enter a number'))
except ValueError:
print('this is not a number')
continue
if x == 0:
print('we dont accept 0')
continue
if x % 2 == 0:
print('we only accept even numbers for some odd reason. no pun intended')
continue
# we manage to reach the end, passing all "guards"
break
#tyNitori
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment