i am getting
RuntimeError: dictionary changed size during iteration
during an iteration of a dictionary to which i am adding new entries. what i am doing is, for each key that has a '_' i am adding another key where each '_' has been replaced with '-'. the existing key is not removed. what is the suggested (pythonic) way around this? the first thought was to assign all the keys to a variable, and iterate that list (or tuple). but that didn't work (got the same error).ks = options.keys() for optkey in ks: if '_' in optkey: options[optkey.replace('_','')] = options[optkey] options[optkey.replace('_','-')] = options[optkey]but ... it is iterating over ks, not the dictionary. so how does it come up with this?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.