Skip to content

Instantly share code, notes, and snippets.

@mIcHyAmRaNe
Created September 23, 2017 22:39
Show Gist options
  • Save mIcHyAmRaNe/d1b734ffc9d8617dd7aa16f9f002afbb to your computer and use it in GitHub Desktop.
Save mIcHyAmRaNe/d1b734ffc9d8617dd7aa16f9f002afbb to your computer and use it in GitHub Desktop.
python3: script that accept only integer and refuse 0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
while True:
try:
x = int(input('enter a number'))
if x == 0:
print('we dont accept 0')
continue
break
except ValueError:
print ('this is not a number')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment