First consider a function for creating just one row This fun
First, consider a function for creating just one row:
This function offers a starting-point for creating one-dimensional lists— but the same idea applies for building nested list structures arbitrarily deep.
createBoard(width, height)
Building on this example, write a function named createBoard(width, height) that creates and returns a new 2D list of height rows and width columns in which all of the data elements are 0 (just a Python list!).
Avoid re-implementing the createOneRow function! Rather, use createOneRow inside your createBoard in the same way that 0 is used to accumulate individual elements in createOneRow. Here is a template -- copy and paste this and then fill in the parts you\'ll need to complete it:
That\'s all you\'ll need! Again, the idea is to follow the example of createOneRow -- but instead of adding a 0 each time, the function would add a whole row of 0s, namely the output from createOneRow!
Test out your createBoard function! For example,
Solution
I will tell you how the output will be obtained.
Test out your createBoard function?
Example 1)
Example 2)
