1
I have the following python function
def playersID(self, listDetals):
listPlayersID = []
tempDict = {}
for x in listDetals:
for y in x['result']['players']:
tempDict.clear()
tempDict['match_id'] = x['result']['match_id']
tempDict.update(y)
listPlayersID.append(tempDict)
return listPlayersID
The "listDetals" parameter is a list of Dict and the return of the function is also a list of Dicionario with a piece of listDetals at each position. The problem is in the command "append".
Every time he is called, he fills ALL the list again, instead of just creating a new position at the end of it. Does anyone have any idea why?
Try to change
tempDict.clear()
fortempDict = {}
and see if it works.– Paulo