I am working on many tables, the number of rows of these tables are not the same. Using a for-loop, I could go through the content of the these tables and put it into two lists. For each iteration of the for-loop, the content of these lists will be changed based on the content of these tables. After that, I am looking to put the content of these lists for each iteration into one list.
For example:
I can go manually to put the contents of two list below into a dictionary, but this should be ok, if I have two lists with known dimensions (the number of rows are known), but if I have two lists with unknown number of rows, this wasn't work.
Table: 1
player1 = ['1','2','3']
player2 = ['4','5','6']
d ={}
d['players'] = {}
d['players']['player1'] = []
d['players']['player1'].append(T1[0])
d['players']['player1'].append(T2[0])
d['players']['player2'] = []
d['players']['player2'].append(T1[1])
d['players']['player2'].append(T2[1])
d['players']['player3'] = []
d['players']['player3'].append(T1[2])
d['players']['player3'].append(T2[2])
print(d)
### {'players': {'player1': ['1', '4'], 'player2': ['2', '5'], 'player3': ['3', '6']}}
if I have other two lists from other table where the number of rows are unknown and want to add to the other dictionary where the values (elements) of the dictionary will changes for each iteration of the for-loop, what can I do?
For example:
Table: 2
player1 = ['7','8','9',.....]
player2 = ['1','4','7',.....]
The dictionary should be:
d = {'players': {'player1': ['7', '1'], 'player2': ['8', '4'], 'player3': ['9', '7'], .......}}
At the end, I want to add these two dictionary above to a list
List = [{'players': {'player1': ['1', '4'], 'player2': ['2', '5'], 'player3': ['3', '6']}}, {'players': {'player1': ['7', '1'], 'player2': ['8', '4'], 'player3': ['9', '7'], .......}}]