I have a dictionary that contains dictionaries called tick_list
, as such:
(1, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
(2, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
(3, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
(4, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
(5, {'Wins: ': 0, 'WinRate: ': 0, 'Total: ': 0})
Let's say I want to add 1 to dictionary 5's Wins:
. I tried:
tick_list[5]["Wins: "] += 1
But this resulted in:
(1, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
(2, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
(3, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
(4, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
(5, {'Wins: ': 1, 'WinRate: ': 0, 'Total: ': 0})
Any explanations as to why that's happening? Any how do I get to to add 1 to only 5's dictionary?
Disregard the brackets ()
instead of {}
, I used a for loop to print the dictionary.