[Tutor] Step Value
Vincent Balmori
vincentbalmori at yahoo.com
Wed Jun 15 21:35:49 CEST 2011
I am still working on that one question in the absolute beginners with the the
ask_number function and step value. Honestly, I still have no idea what to do.
This is one of my many attempts, but I know that it's wrong.
def ask_number(question, low, high):
"""Ask for a number within a range."""
response = None
if response in range(low, high, 1):
return response
while response not in range(low, high):
response = int(input(question))
return response
I tried to find clues by looking at the later section that calls on the
ask_number function:
def human_move(board, human):
"""Get human move."""
legal = legal_moves(board)
move = None
while move not in legal:
move = ask_number("Where will you move? (0 - 8):", 0, NUM_SQUARES)
if move not in legal:
print("\nThat square is already occupied, foolish human. Choose
another.\n")
print("Fine...")
return move
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110615/df43732b/attachment.html>
More information about the Tutor
mailing list