How to fix RuntimeError: dictionary changed size during iteration in Python | DevErrors