import random def roll_dice(): return random.randint(1, 6) def play_game(): player_scores = [0, 0] player_names = ["Player 1", "Player 2"] current_player = 0 print("Welcome to the Dice Game!") print("First player to reach 20 points wins!") while True: input(f"{player_names[current_player]}'s turn! Press Enter to roll the dice...") roll = roll_dice() player_scores[current_player] += roll print(f"{player_names[current_player]} rolled a {roll}. Current score: {player_scores[current_player]}") if player_scores[current_player] >= 20: print(f"{player_names[current_player]} wins with a score of {player_scores[current_player]}!") break current_player = (current_player + 1) % 2 # Switch players if __name__ == "__main__": play_game()