I have a dictionary that has keys of different word lengths, for example:
d={'longggg':'a', 'short':'b', 'medium':'c', 'shor':'d'}
and I want to end up with a dictionary that only has keys that are greater than a certain length. For example, I want to only keep entries that are 6 letters long or more. So I want
new_d={'longggg':'a', 'medium':'c'}.
I tried
new_d=dict(k,v) for k,v in d.items() if len[k]>=6
and
new_d={}
for k, v in d.items():
if len[k]>=6:
new_d.update({k:v})
along with many other variations of that code, but the problem ends up being in taking the length of a key.