that brings us to the choosedice method here we must implement more extensive user interaction the choosedice method returns list of the indexes of the dice that the user wishes to roll in our guithe user will choose dice by clicking on corresponding buttons we need to maintain list of which dice have been chosen each time die button is clickedthat die is either chosen (its index is appended to the listor unchosen (its index is removed from the listin additionthe color of the corresponding dieview reflects the status of the die the interaction ends when the user clicks either the roll button or the score button if the roll button is clickedthe method returns the list of currently chosen indexes if the score button is clickedthe function returns an empty list to signal that the player is done rolling here is one way to implement the choosing of dice the comments in this code explain the algorithmdef choosedice(self)choices is list of the indexes of the selected dice choices [no dice chosen yet while truewait for user to click valid button self choose(["die ""die ""die ""die ""die ""roll dice""score"]if [ =" "user clicked die button eval( [ ] translate label to die index if in choicescurrently selectedunselect it choices remove(iself dice[isetcolor("black"elsecurrently unselectedselect it choices append(iself dice[isetcolor("gray"elseuser clicked roll or score for in self dicerevert appearance of all dice setcolor("black"if ="score"score clickedignore choices return [elif choices ![]don' accept roll unless some return choices dice are actually selected that about wraps up our program the only missing piece of our interface class is the close method to close up the graphical versionwe just need to close the graphics window def close(self)self win close(finallywe need few lines to actually get our graphical poker playing program started this