Question: Implement function yahtzee() that rolls 5 dices (numbered 0 through 4) three times and prints the result after each roll. After each roll of the

Implement function yahtzee() that rolls 5 dices (numbered 0 through 4) three times and prints the result after each roll. After each roll of the dice, the player is asked whether she wants to save one or more of the dice rolls. Here is an example usage:

>>> yahtzee() You have 6, 3, 3, 5, and 4 What dice do you want to save? 1,2 You have 5, 3, 3, 1, and 6 Whatdice do you want to save? 1,2 You have 3, 3, 3, 3, and 5 Write your score.

The result of the first roll for the five dice is 6, 3, 3, 5, and 4. The player chooses to save the result for dice 1 and 2 (the two 3s). During the second roll only the "unsaved" dice will be rolled, i.e. dice 0, 3, and 4. After that roll, the player decides to again save the two 3s. After the third roll, involving only dice 0, 3, and 4, the final value of the dice is obtained. Here are a few more examples:

>>> yahtzee() You have 2, 1, 4, 6, and 2 What dice do you want to save? 0,4 You have 2, 5, 4, 6, and 2 Whatdice do you want to save? 1,2,3 You have 2, 5, 4, 6, and 1 Write your score. >>> yahtzee() You have 5, 4, 1, 6, and 3 What dice do you want to save? 0,1,3,4 You have 5, 4, 3, 6, and 3 Whatdice do you want to save? 0,1,2,3

You have 5, 4, 3, 6, and 4 Write your score.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!