I'm trying to create a function with three parameters: x,y,val that will return a two dimensional array with x rows and y columns and every single value initialized to val. e.g.
myList = createList(2,3,"-")
would create the resulting list: [["-", "-", "-"] ["-", "-", "-"]]
so far I've created the following function for this but it puts all the initial values on one list:
def createList(x,y,val):
myList=[]
for i in range(x):
for j in range(y):
myList.append(val)
return myList
print(createList(2,3,"-"))
which creates the output: ['-', '-', '-', '-', '-', '-']