Skip to content

Instantly share code, notes, and snippets.

@dboyliao
Created August 11, 2016 15:39
Show Gist options
  • Save dboyliao/b2eefa4c00b76c63f0c14d5deb8945bf to your computer and use it in GitHub Desktop.
Save dboyliao/b2eefa4c00b76c63f0c14d5deb8945bf to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from __future__ import print_function
import sys
if sys.version_info.major < 3:
input = raw_input
def main():
while True:
user_input = input("pleas enter a number: ")
try:
user_int = int(user_input)
if user_int > 0:
print("you just entered: {}".format(user_int))
else:
print("it is not a positive number")
except ValueError:
print("it is not a number")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment