>>> d = {float('nan'): 1} >>> d {nan: 1} >>> del d[float('nan')] Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: nan