Python Forum
Change list which is in a function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change list which is in a function
#1
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?
Reply
#2
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)
Reply
#3
is your goal the equivalent of passing a value into one function and getting it out via another function?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Change font in a list or tuple apffal 4 3,692 Jun-16-2023, 02:55 AM
Last Post: schriftartenio
  How to change the datatype of list elements? mHosseinDS86 9 3,546 Aug-24-2022, 05:26 PM
Last Post: deanhystad
  find some word in text list file and a bit change to them RolanRoll 3 2,338 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  Change a list to integer so I can use IF statement buckssg 3 3,142 Sep-21-2021, 02:58 AM
Last Post: bowlofred
  change csv file into adjency list ainisyarifaah 0 1,863 Sep-21-2021, 02:49 AM
Last Post: ainisyarifaah
  write new function or change the old one to work "smartter? korenron 3 2,739 Aug-09-2021, 10:36 AM
Last Post: jamesaarr
  How to change odd to even numbers in the list? plumberpy 8 5,405 Aug-08-2021, 11:07 AM
Last Post: plumberpy
  Question about change hex string to integer sting in the list (python 2.7) lzfneu 1 3,278 May-24-2021, 08:48 AM
Last Post: bowlofred
  LIST or ARRAY Comparison and change of value nio74maz 0 2,173 Dec-21-2020, 05:52 PM
Last Post: nio74maz
Question dict value, how to change type from int to list? swissjoker 3 3,502 Dec-09-2020, 09:50 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020