I have to get rid of all the entries which have negative value. Why is my code not working?
dic = {'aa': 20, 'bb': -10, 'cc': -12}
for i in dic:
if dic[i] < 0:
del dic[i]
print(dic)
When running this code I get an exception:
RuntimeError: dictionary changed size during iteration