Reputation: 20841
The pseudo code is in notes but I need to define a function that checks the valid moves left in my peg game. The game pretty much randoms two die and it takes the sum of those two numbers and the person pegs the numbers in the list from 1-10 that they roll. In this portion of it I need to return the portion of the list that has not been pegged. Obviously my code is not right but I do not know how to do this part of the game so any help fixing my code would be appreciated, thanks.
PEGGED = "X"
# This function will return a list of numbers, which are free (don't
# have pegs in them), a.k.a., a list of valid moves
def valid_moves(pegholes):
validMoves = item in len(range(0, pegholes, 1)) != PEGGED
return validMoves
Upvotes: 0
Views: 78
Reputation: 298582
This logic might work:
validMoves = [item for item in pegholes if item != PEGGED]
Upvotes: 3