I'm creating a utility program whose functions will be used as part of another program.
This is my function (EDITED):
def push_up (grid):
new_grid = up_down_swapper(grid)
new_grid = zero_DR(new_grid)
for i in range(4):
for j in range(3):
if new_grid[i][j] == new_grid[i][j+1]:
new_grid[i][j+1] = (new_grid[i][j])+(new_grid[i][j])
new_grid[i][j] = 0
else:
pass
new_grid = zero_DR(new_grid)
grid = up_down_swapper(new_grid)
#print(grid) - shows the grid as the expected outcome. But outside of the function it doesn't change
and here is how it's used:
push.push_up (grid)
As you guys can see it isn't being assigned to a value like
new_grid = push.push_up (grid)
I cannot change the main program ( this is an assignment and this is what I've been told to do.)
My problem is how do I get the function to change the value of the parameter? I'm not sure if I'm making sense but something like this:
def square(x):
x = x*x
value = 3
square(value)
print(value)
This will output 3, but I'm wanting 9. How would I go about doing this?
Here is a pastebin of the main code: http://pastebin.com/NAxWL14h