Have a dictionary which has a list of dictionaries which will be altered but getting the error:
RuntimeError: dictionary changed size during iteration
This was working with python2 but not with python3. How to make it work with python3?
multi_van_data = {'Van1': [{'ClusterStops': [], 'OptimalStop': 'GSV07858'},
{'ClusterStops': [], 'OptimalStop': 'GSV07932'},
{'ClusterStops': [], 'OptimalStop': 'GSV07903'},
{'OptimalStop': 'GSV07892', 'ClusterStops': ['GSV07903']}]}
for k, v in multi_van_data.items():
for val in v:
val['ParentSequence'] = route.index(val['OptimalStop']) + 1
val['ParentServiceTime'] = 1
val['ParkstopTravelTime'] = 1
val['ApproxCompletionTime'] = []
cluster_stops = val['ClusterStops']
print cluster_stops
val.pop('ClusterStops')
Want to remove all ClusterStops