我正在尝试删除其值列表中包含“F”的键 (102),如下所示
grades = {101:['A','HD'],102:['D','F'],103:['B','CR'],104:['B','CR'],105:['A','HD'],106:['C','P']}
for k,v in grades.items():
if 'F' in v: # if v[1] == 'F':
del grades[k] # grades.pop(k)
我收到错误
RuntimeError: dictionary changed size during iteration
如何在不遇到该错误的情况下删除它?