From d9447199288d808920cd468980098d36c9f80137 Mon Sep 17 00:00:00 2001 From: Jaso Salgado Date: Mon, 22 Jun 2020 16:03:57 -0500 Subject: [PATCH] Solved --- challenge.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/challenge.py b/challenge.py index 93a85f8..c9bf095 100644 --- a/challenge.py +++ b/challenge.py @@ -72,13 +72,32 @@ ] +def homeless(data): + new_data = dict(data) + new_data['homeless'] = True if new_data['organization'] == '' else False + return new_data + + +def old(data): + new_data = dict(data) + new_data['old'] = True if new_data['age'] > 30 else False + return new_data + + def run(): + # Using filter, generate a list with all the python devs + all_python_devs = filter(lambda x: x['language'] == 'python', DATA) + + # Using filter, generate a list with all the Platzi workers + all_Platzi_workers = filter(lambda x: x['organization'] == 'Platzi', DATA) + + adults = filter(lambda x: x['age'] >= 18, DATA) - 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 map, generate a new list of people with a key 'homeless' with True or False values, if 'organization' have something or not + workers = map(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 = map(old, DATA) print('Python devs: ') for dev in all_python_devs: