I'm trying to implement this function but I'm not sure exactly how to do so. I know we have to use a for loop for this problem but as with setting with variables and such, or if it contains a nested for loop, I am unsure.
def reshape(thelist, rows, cols):
"""Returns: A rows*cols 2D list with the contents of thelist
Hint: In a 2D list, the element at row x and col y is the
x*cols+y element listed.
Example: reshape([1,2,3,4],2,2) returns [[1,2], [3,4]]
Example: reshape([1,2,3,4,5,6],3,2) returns [[1,2], [3,4], [5,6]]
Example: reshape([1,2,3,4,5,6],2,3) returns [[1,2,3] ,[4,5,6]]
Precondition: thelist is a list of numbers of size rows*cols. rows
and cols are positive integers."""