Skip to content

Instantly share code, notes, and snippets.

@kaydell
Created October 9, 2013 17:41
Show Gist options
  • Save kaydell/6905184 to your computer and use it in GitHub Desktop.
Save kaydell/6905184 to your computer and use it in GitHub Desktop.
A Python 3 Demo of Asking the User To Input An Int
# This script is a demonstration of asking the user to enter an
# int in Python 3
# ask the user to enter an int
string = input("Please enter an int: ")
# the function input() returns a str we need to convert it to be an int
n = int(string)
# echo the int back to the user
print("You entered: %d" % (n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment