# RepeatableGame.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2013-10-10 File created. # 2022-12-27 Converted to Python 3. # This is an improved version of program Game.py. # In this program, the 'game' is played inside a while loop, and # the user is given the possibility to play several games during # a single run of this program. user_wants_to_play_more = True while user_wants_to_play_more == True : print( "\n This program is a computer game." \ "\n Please, type in an integer : ", end="" ) integer_from_keyboard = int( input() ) one_larger_integer = integer_from_keyboard + 1 print( "\n You typed in %d." % integer_from_keyboard, end="" ) print( "\n My number is %d." % one_larger_integer, end="" ) print( "\n Sorry, you lost. I won. The game is over." ) print( "\n You want to play more (Y/N) ? ", end="" ) # User input will be 'stripped' of whitespace characters, # and it will be converted to uppercase character(s). user_choice = input().strip().upper() if not user_choice == "Y" : user_wants_to_play_more = False