I have the following data from a dictionary in python
.
The problem that I am facing is the empty string as key and value in the dictionary.
data = {'id': '213', 'first_name': 'john', 'last_name': 'doe', '': ''}
my goal is to delete the empty string key
and create a new dictionary without it
so I tried:
from copy import deepcopy
for x, y in data.items():
if x == "":
del data[x]
new_data = deepcopy(data)
print(new_data)
but for some reason, I am getting the following error
...
for x, y in data.items():
RuntimeError: dictionary changed size during iteration
am I missing something?