Created
September 23, 2017 22:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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