Python Forum

Full Version: Change list which is in a function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello guys,
I created a list into a function: 
n=eval(input("Enter a number of rows: "))
p=eval(input("Enter a number of columns: "))
def newBoard(n=5,p=4):
        a=[[1]*p for i in range(2)]
        b=[[0]*p for i in range(n-4)]
        c=[[2]*p for i in range(2)]
        grid=a+b+c
        return(grid)
now, I want to create another function:
"def display(board,n,p):"
and I want to put the list grid in my function newBoard into the parameter of display as board (board=grid)
Someone knows how can I do this pls?
Get the return value from one function and pass it to another function.
def some_function():
    return 'somevalue'

def another_function(passed_in):
    print(passed_in)

the_value = some_function()
another_function(the_value)
is your goal the equivalent of passing a value into one function and getting it out via another function?