[Tutor] Variables and Functions
macintyredev at gmail.com
Wed Nov 28 22:00:24 CET 2007
Just wondering, how would I get a variable out of one function and into
another? I'm trying to make a Sudoku puzzle for Python 2.5.1, and in one
function I have the finished puzzle (as a matrix) called 'puzzle'. Using the
'copy' module I made a deep copy called 'new_puzzle'. That function is
called to create the puzzle and its duplicate, because new_puzzle gets
changed so that 85% of the numbers in the matrix get replaced by an empty
string. Now, I have another function that allows you to choose the where on
the grid to put in the number, but I also need to get new_puzzle in that
function to add numbers not only on the Turtle grid, but add them in
new_puzzle so I can compare it with the original 'puzzle' variable.
PS: Both functions 'new_sudoku()' and 'play_game()' are called by a function
called 'new_game()'. Also, I'm using a Mac, but I'm not sure if that affects
the code or not.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor