Last active
September 16, 2015 04:02
-
-
Save DavisDevelopment/f655392ce5043437cfa8 to your computer and use it in GitHub Desktop.
Super-Simple Python3 "Prompt" class
This file contains hidden or 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
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