Skip to content

Instantly share code, notes, and snippets.

@DavisDevelopment
Last active September 16, 2015 04:02
Show Gist options
  • Save DavisDevelopment/f655392ce5043437cfa8 to your computer and use it in GitHub Desktop.
Save DavisDevelopment/f655392ce5043437cfa8 to your computer and use it in GitHub Desktop.
Super-Simple Python3 "Prompt" class
class Prompt( object ):
# Constructor Function
def __init__(self, msg):
self.message = msg
# Method to get the input as a String
def get_string(self):
return (input(self.message).strip())
# Method to get the input as an Int
def get_int(self):
return int(self.get_string())
# Example Usage
# - get name and age of user
namep = Prompt("What is your name? ")
agep = Prompt("How old are you? ")
name = namep.get_string()
age = agep.get_int()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment