Pythonn error message:
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\python.exe c:/users/administrator/ pycharmprojects/pythondemo/maptest.py
Traceback (most recent):
File "c:/users/administrator/pycharmprojects/pythondemo/maptest.py", line 5, <module>
For line in Maps.keys ():
Runtimeerror:dictionary changed size during iteration
# Python2 The elements in the dictionary while the traversal is implemented, and the error message is run in Python3:
"""
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\python.exe c:/users/administrator/ pycharmprojects/pythondemo/maptest.py
Traceback (most recent):
File "c:/users/administrator/pycharmprojects/pythondemo/maptest.py", line 5, <module>
For line in Maps.keys ():
Runtimeerror:dictionary changed size during iteration
"""
# maps = {1: "Li Ming", 2: "Danny"}
# for line in Maps.keys ():
# if (line = = 2):
# Maps.pop (line)
# Print (MAPS)
# Python3 to delete elements in a dictionary while implementing traversal
Maps = {1: "Li Ming", 2: "Danny"}
For line in list (Maps.keys ()):
if (line = = 2):
Maps.pop (line)
Print (MAPS)
Python error runtimeerror:dictionary changed size during iteration