My goal is to write a function, which receives a list of class objects and converts these into a list of lists, this is what I currently have:
def convertToListOfLists(toConvert):
listOfLists = []
temp = []
for t in toConvert:
temp.append(t.datenbestand)
temp.append(t.aktenzeichen)
temp.append(t.markendarstellung)
temp.append(t.aktenzustand)
listOfLists.append(temp)
temp.clear()
print(listOfLists)
return listOfLists
Output: [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []]
while 'toConvert' holding 17 objects
If I move the print into the loop and print out my 'listOfLists' I can see that the objects are added to my 'listOfLists' correctly but as you can see, if I access 'listOfLists' outside the loop, 'listOfLists' only holds empty lists.
What am I missing?