I would go with the basic way: EDIT: fixed code formatting to return None outside of loop
for key, sets_list in d.items(): for sets in sets_list: if target_number in sets: return key return None