I'm a uni student who took an intro computer science course as an elective. I'm in social sciences so this class is way out of my comfort zone. I'm practicing for the upcoming final exam but I am stuck on one of the questions. It would be great of someone could help me figure this out.
def v_to_id(id: Dict[str, Dict[str, str]], name: str) -> Dict[str, List[str]]: """Return a dictionary, in which the keys are all possible values of name that appear in id, and the values are lists of all patient IDs that have that value for this attribute name. Precondition: name is a name of an attribute that appears in id_to_attributes. >>> value_to_ids = build_value_to_ids(THREE_PATIENTS, 'Gender') >>> expected = {'male': ['tcga.aq.a54o'], ... 'female': ['tcga.5l.aat0', 'tcga.aq.a7u7']} >>> same_key_to_list_dicts(expected, value_to_ids) True """ vals = {} idd = [] cat = [] for k,v in id_to_attributes.items(): for value in v: if value == name: idd.append(value, k) for value in v: if return vals
Submitted April 02, 2019 at 07:46PM by uoftearsstudent https://ift.tt/2FTxFYj
No hay comentarios:
Publicar un comentario