From 9cdd4bdea150a3c68616d63af06cf99d96a5b5b5 Mon Sep 17 00:00:00 2001 From: Ulzahk Date: Wed, 2 Sep 2020 14:26:35 -0500 Subject: [PATCH 1/2] Challenge's Answer --- challenge.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/challenge.py b/challenge.py index 93a85f8..60e0f84 100644 --- a/challenge.py +++ b/challenge.py @@ -73,12 +73,16 @@ def run(): - - all_python_devs = # Using filter, generate a list with all the python devs - all_Platzi_workers = # Using filter, generate a list with all the Platzi workers - adults = # Using filter, generate a list with all people over 18 years old - workers = # Using map, generate a new list of people with a key 'homeless' with True or False values, if 'organization' have something or not - old_people = # Using map, generate a new list of people with a key 'old' with True or False values, if 'age' is greater than 30 or not + # Using filter, generate a list with all the python devs + all_python_devs = filter( lambda person: person['language'] == 'python' , DATA) + # Using filter, generate a list with all the Platzi workers + all_Platzi_workers = filter (lambda person: person['organization'] == 'Platzi', DATA) + # Using filter, generate a list with all people over 18 years old + adults = filter (lambda person: person['age'] > 18, DATA) + # Using map, generate a new list of people with a key 'homeless' with True or False values, if 'organization' have something or not + workers = list(map(lambda person: person.update({'homeless': (True if person['organization'] else False)}) or {'name': person['name'], 'organization': person['organization'],'homeless': person['homeless']}, DATA)) + # Using map, generate a new list of people with a key 'old' with True or False values, if 'age' is greater than 30 or not + old_people = list(map(lambda person : person.update({'old': (True if person['age'] > 30 else False)}) or {'name': person['name'], 'age' : person['age'], 'old': person['old']}, DATA)) print('Python devs: ') for dev in all_python_devs: From 558ea5ebeab9601a2455db118567276394377b80 Mon Sep 17 00:00:00 2001 From: Ulzahk Date: Wed, 2 Sep 2020 14:36:20 -0500 Subject: [PATCH 2/2] Workers's list fixed --- challenge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/challenge.py b/challenge.py index 60e0f84..5b35eb2 100644 --- a/challenge.py +++ b/challenge.py @@ -79,8 +79,8 @@ def run(): all_Platzi_workers = filter (lambda person: person['organization'] == 'Platzi', DATA) # Using filter, generate a list with all people over 18 years old adults = filter (lambda person: person['age'] > 18, DATA) - # Using map, generate a new list of people with a key 'homeless' with True or False values, if 'organization' have something or not - workers = list(map(lambda person: person.update({'homeless': (True if person['organization'] else False)}) or {'name': person['name'], 'organization': person['organization'],'homeless': person['homeless']}, DATA)) + # Using map, generate a new list of people with a key 'homeless' with False or True values, if 'organization' have something or not + workers = list(map(lambda person: person.update({'homeless': (False if person['organization'] else True)}) or {'name': person['name'], 'organization': person['organization'],'homeless': person['homeless']}, DATA)) # Using map, generate a new list of people with a key 'old' with True or False values, if 'age' is greater than 30 or not old_people = list(map(lambda person : person.update({'old': (True if person['age'] > 30 else False)}) or {'name': person['name'], 'age' : person['age'], 'old': person['old']}, DATA))