Please Help
LukeBreeden1 (1)

Ok... I'm am trying to code a Yahtzee game with python and am having a bit of trouble. I'm new to python and heard that a dice game is a simpler task for beginners(guess I picked the wrong game). Anyway, what I'm having trouble with is that I'm trying to make a connection between the numbers rolled and the numbers the player chooses to keep. Can anyone help me... I can share if that is what's needed.

You are viewing a single comment. View All
Elizabeth11 (20)

@LukeBreeden1 You can create 2 lists. I'll call one roll_list and another player_choosen_list. You can change the names. Anyway, roll_list holds all of the intial numbers. Then print out these numbers and you can ask the player "do you want to keep a number?" then while the player says "yes" then have them input the number they want to keep. Add this number to the player_chosen_list Once the player answers the question "do you want to keep a number" with something other then yes then the boolean variable would be false and you could end the while loop. Then because you want to keep the numbers that are chosen so that they won't get rerolled take the initial list which is roll_list and loop through it and use a nested loop to check if there is a number that is inside of both the roll_list and the player_choosen_list. If so remove that number from the roll_list. Once the for-loops are done then reroll using the roll_list and you may have the reset the player_chosen_list.