Change list which is in a function - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Change list which is in a function (/thread-790.html) |
Change list which is in a function - zakobenayoun - Nov-05-2016 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? RE: Change list which is in a function - Yoriz - Nov-06-2016 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) RE: Change list which is in a function - Skaperen - Nov-06-2016 is your goal the equivalent of passing a value into one function and getting it out via another function? |