i'm learning python and hit a wall. I am trying to define a 2d list which i can later use to append values. This corresponding to a grid of width *height
I tried using [] to initialize the empty lists but then the wid is ignored. I tried using None as a placeholder but then i can't append
wid = 3
hgt = 3
l1 = [[]*wid ] * hgt
l = [[None]*wid ] * hgt
l[1][1].append("something")
Result
l1: [[], [], []]
l: [[None, None, None], [None, None, None], [None, None, None]]
Error:
append: AttributeError: 'NoneType' object has no attribute 'append'
desired result: [[[], [], []], [[], [], []], [[], [], []]]