I have a loop to populate a list, using a loop format.
I'm supposed to create a list, then - using a loop - populate the list with N elements, and set each list element to its index multiplied by 10.
It is also possible that N will be 0. In this case I'm supposed to output an empty list [], and this what I think is tripping me up.
list = [N]
for x in range(N):
innerlist = []
for y in range(N):
innerlist.append(list)
list.append(innerlist)
if N == 0:
list = []
print (list)
I thought that the if(N==0) statement would reset the value of the list but it doesn't. I should output [] but instead I output [0].
lstfor a variable name, notlist.