Mar-28-2017, 10:31 PM
I would put it into a method of the class, if it has to be a class:
class Prompter(object): def __init__(self, prompt_message): self.prompt_message = prompt_message def main(self): prompt_username = input(self.prompt_message) if prompt_username.lower() != 'quit': print('Welcome to a whole new world, {}.'.format(prompt_user_name))I took out the loop since there didn't seem to be any point to it (you break out of it no matter what the input is). If the loop is meant to be expanded on as you develop the program, you can just put the whole loop into the main method. To use it, just instantiate and call:
prompter = Prompter("Enter the username you wish to create. \nType 'quit' if you wish to exit: ") prompter.main()Note that you don't need to backslash single quotes if you are using double quotes to define the string constant.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures