Replace list(somedict.keys()) by simply somedict.