So I’m creating a very basic python game and I need some help with this step I’m stuck at. The concept of the game is for the program to roll two die and add the sums. With that number they can choose a number available from the number list (1-10) to “peg”. They keep going until all numbers are pegged or are out of options. Earlier in the program I created two functions that I’m using in this step. Those two are ask_number and valid_moves. Basically the ask number just asks them which number they want to peg but it doesn’t actually peg the number yet. The valid_moves function just checks which numbers are still available for the player to select.
The game pretty much just looks like this halfway through:
------------------------------ (1)(2)(3)(4)(X)(6)(7)(X)(9)(X) ------------------------------
The X are the numbers that were already pegged. In this part of the game I need to figure out how to replace the number with “X”. I have this so far but I know I am way off and I am having trouble with figuring out what to do. (pegholes is the name of the list and move is the number they picked in the ask_number function). Thanks so much!
PEGGED = "X"
def enter_peg(pegholes, roll, total):
ask_number()
if ask_number == valid_moves():
pegholes.append(ask_number(PEGGED))
return pegholes, move
I am really not sure how your game is supposed to work, but this may help you out: