game_record = [['*', 'G02', 'G05', 'G07', 'G08', 'G10'],
['P001', '1', '0', '-1', '503', '1'],
['P067', '1', '1', '0', '-1', '503'],
['P218', '0', '1', '1', '-1', '-1'],
['P101', '0', '0', '1', '1', '503'],
['P456', '1', '1', '-1', '1', '-1']]
Info for game_record list data:
- * = nothing, just a sign
- GXX = game_id
- PXXX = player_id
- 1 = playing game and win (game finished and recorded)
- 0 = playing game and lose (game finished and recorded)
- -1 = not playing the game (not recorded)
- 503 = in an on-going game (game not finished and not recorded)
for example:
- G02 has been played and finished by 5 players with total of 3 players win and 2 players lose.
- G08 has been played and finished by 2 players with total of 2 players win.
therefore only '1' and '0' matter for the record.
I want to loop this 2D-list to count how many times each game (game_id) has been played, win, and lose by a player. Then store them to dictionary.
Expected Output:
Game_info = {G02: [5, 3, 2], G05: [5, 3, 2], G07: [3, 2, 1], G08: [2, 2, 0], G10: [1, 1, 0]}