turn_over is a small Python function that decides whether a player's dice turn has ended. It accepts the latest list of rolls and returns True when the list contains a 1 or has exactly five rolls; otherwise, it returns False. section 10.4.2 section 10.4.3
Read the function as an input-process-output task:
- Input: rolls, a list containing the player's most recent dice rolls. section 10.4.3
- Process: check whether 1 appears in the list or whether its length equals five. section 10.4.3
- Output: return True when either condition ends the turn, and False otherwise. section 10.4.2
A compact implementation
def turn_over(rolls): return 1 in rolls or len(rolls) == 5 For [2, 4, 6], the result is False. For [2, 1, 6], it is True because a 1 was rolled. For five rolls without a 1, it is also True: reaching five dice ends the turn regardless of the values. section 10.4.3
Figure 10.6 Top-down design for the Bogart game
Use the top-down design figure to see turn_over as one subtask inside the larger full-turn game process. section 10.4.2
