diff --git a/challenge.py b/challenge.py index 93a85f8..b3132e3 100644 --- a/challenge.py +++ b/challenge.py @@ -74,11 +74,43 @@ 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 + # Normal: [value for value in DATA if value['language'] in 'python'] + # Using filter, generate a list with all the python devs + all_python_devs = filter( + lambda value: value['language'] in 'python' and value['language'], DATA) + + # Using filter, generate a list with all the Platzi workers + all_Platzi_workers = filter( + lambda value: value['organization'] in 'Platzi' and value['organization'], DATA) + + # Using filter, generate a list with all people over 18 years old + adults = filter( + lambda value: value['age'] > 17 and value['age'], DATA) + + # 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 = list(dict.fromkeys(map(lambda value: value['organization'] + # if value['organization'] else 'homeless', DATA))) + workers = list(map( + lambda value: value if value['organization'] else { + 'name': value['name'], + 'age': value['age'], + 'organization': 'homeless', + 'position': value['position'], + 'language': value['language'], + }, DATA)) + + # 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 + # old_people = list(dict.fromkeys(map(lambda value: value['age'] + # if value['age'] > 30 else 'old', DATA))) + old_people = list(map( + lambda value: value + if value['age'] > 30 else { + 'name': value['name'], + 'age': 'old', + 'organization': value['organization'], + 'position': value['position'], + 'language': value['language'], + }, DATA)) print('Python devs: ') for dev in all_python_devs: