Jul-28-2019, 01:31 PM
I would choose a better layout.
Example
Example
def get_user_input(allowed=[], message='Choose: '): while True: user_input = input(message).lower().strip() if user_input in allowed: return user_input elif user_input in ['quit', 'exit']: print("Bye for now\n") exit() else: print('Try again') def levelone_begin(): print('Welcome to your adventure.') print('Are you ready? yes/no') print('1 for yes') print('2 for no') user_input = get_user_input(['1', '2']) if user_input == '1': print('_' * 100) print('Alright, Lets begin') return levelone_awake elif user_input == '2': print('_' * 100) print('Maybe later\n') exit() def levelone_awake(): print('_'*100) print('You awaken to find youself in a dimly lit cavern, beside you lies a sword and a shield ') print('do you want to pick them up') print('1 for yes') print('2 for no') user_input = get_user_input(['1', '2']) if user_input == '1': print('_'*100) print('You stand up, dust yourself off while trying to ignore your throbbing head, grab the weapons on the ground,') print('look around and see a door ajar.') elif user_input == '2': print('clooock') return levelone_awake def main(): while True: question = levelone_begin while question: question = question() user_input = get_user_input(['y', 'n', 'yes', 'no'], 'Play Again? Y or N: ') if user_input == 'N': print ('Goodbye!') exit() print('Goodluck!\n') main()
99 percent of computer problems exists between chair and keyboard.