"From Steven D'Aprono: * change the ask_number function to accept a fourth argument; * make it optional rather than required; * give it a sensible default value; * within the function, that value must then be passed to range "
Okay, I think I understand it better for the quesiton: "Improve the function ask_number() so that the function can be called with a step value. Make the default value of step 1." Here is the improved function and the human_move function that calls it later on. The thing I am unaware of doing is making the step value 'optional rather than required' though. def ask_number(question, low, high, step): """Ask for a number within a range.""" step = 1 response = None while response not in range(low, high, step): response = int(input(question)) return response 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, 1) if move not in legal: print("\nThat square is already occupied, foolish human. Choose another.\n") print("Fine...") return move
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor