import random def roll_dice(): return random.randint(1, 6) def display_roll_info(roll_number, dice1, dice2, score, total_score): print(f'Roll {roll_number} ----------------------') print(f'You roll {dice1} and {dice2}') print(f'Your score is {score}') print(f'Your total score is {total_score}') def main(): total_score = 0 roll_number = 1 while True: dice1 = roll_dice() dice2 = roll_dice() score = dice1 + dice2 if dice1 == 1 and dice2 == 1: print('Game over') print(f'Your final score is {total_score}') break display_roll_info(roll_number, dice1, dice2, score, total_score) user_input = input('Do you want to roll again? y/n ') if user_input.lower() != 'y': break total_score += score roll_number += 1 if __name__ == "__main__": main()