I am just starting to learn a bit of Python. I am working with some basic dictionaries. I have a dictionary, which I make a copy of. I then take another dictionary and take the values away from my copy:
teams_goals = {'chelsea' : 2, 'man u' : 3,'Arsenal':1,'Man city':2}
print teams_goals
test_teams = {'chelsea' : 1, 'man u' : 1,'Arsenal':1}
teams_goals_copy = teams_goals.copy()
for team in test_teams:
for j in range(test_teams[team]):
teams_goals_copy[team]= teams_goals_copy[team]- 1
print teams_goals_copy
This leaves me with a dictionary that has some zero values. What I want is a method of removing items from the dictionary when the they are equal to zero.
I found this previous thread here; seems like this used to work on a previous version, but I do not understand the workaround.