print(" Welcome to the 100 game
")
print("To start the game you have to enter a number between 1 to 10")
print("To end the game you have to reach the number 100")
print("First one reach 100 win
")
print("Good luck
")
nums = 0
def display_state():
global nums
print("100/",nums)
def get_input(player):
valid = False
while not valid:
message = player + " player please enter the number between 1 and 10: "
move = input(message)
if move.isdigit():
move = int(move)
if move in range(1, 11) and nums + move <= 100:
valid = True
return move
def update_state(nums_taken):
global nums
nums += nums_taken
def is_win():
global nums
if nums > 99:
return True
def play__100_game():
display_state()
while (True):
first = get_input("First")
update_state(first)
display_state()
if (is_win()):
print("First player won")
break
second = get_input("Second")
update_state(second)
display_state()
if (is_win()):
print("Second player won")
break
play__100_game()