I have a list of dictionaries, where both the key and value are strings. I am importing the data from a CSV file. The dictionaries look like this:
{'1A': '1',
'1B': '1',
'1C': '2'}
I would like to change the values into integers.
I have looked around for a solution but I don't seem to find anything that works.
This is my code (the list is called 'buyers'):
for i in buyers:
for k, v in i.items():
i[v] = int(i[v])
I receive this error:
i[v] = int(i[v])
KeyError: '1'
I'm not sure what to do because it says my error is the '1', which seems to me like it should be able to be converted into an int.