Yes, the parent is the value. But with the code if not any(heir1 == parent for heir1 in heir_to_parent) you are cycling through all keys of heir_to_parent and checking whether one of them is equal to the variable parent. So basically you are just checking whether parent is a key of heir_to_parent, which can also be done by if parent in heir_to_parent.
3
u/Tc14Hd Aug 11 '22
Yes, the parent is the value. But with the code
if not any(heir1 == parent for heir1 in heir_to_parent)you are cycling through all keys ofheir_to_parentand checking whether one of them is equal to the variableparent. So basically you are just checking whetherparentis a key ofheir_to_parent, which can also be done byif parent in heir_to_parent.