Using the clear
-method on a list also affects all references to it, e.g.
>>a = [1, 2, 3]
>>b = a
>>a.clear()
>>print('a=",a)
a = []
>>print("b =',b)
b = []
So what you are doing in ad_list.append(tempAdList)
is to repeatedly add references to the same object to ad_list
, i.e. each time you update tempAdList
, the same update is done for each of those references. What you really want to do is reset tempAdList
with a new object, so replace tempAdList.clear()
with tempAdList=[]
.
solved I want to create a list of lists