You don't need to use .keys() here -- iteration over a dict already iterates over the keys.