python game of stones. Please help
Here's my code numStones = 100 def isValid(player1): try: player1 = int(player1) if player1 in range(6): return True else: return False except ValueError: return False while numStones > 0: print "Welcome to this game of stones, there are now %s stones remaining in the pile" % (numStones) player1 = isValid(raw_input('enter integer')) while not isValid(player1): print 'boo' For some reason, even though I have tested my isValid statement, and it returns True and False as expected, I am not able to access it with the while not isValid statement? how come?
When you call isValid() with raw_input, you're passing a string. The boolean that isValid() returns is assigned to the player1 variable. Then you call isValid() with the boolean in the while statement.
Join our real-time social learning platform and learn together with your friends!