diff --git a/.gitignore b/.gitignore index 3b0a778..eebfa94 100644 --- a/.gitignore +++ b/.gitignore @@ -112,7 +112,7 @@ venv/ ENV/ env.bak/ venv.bak/ - +reto07/ # Spyder project settings .spyderproject .spyproject diff --git a/challenge.py b/challenge.py index 93a85f8..f7faea6 100644 --- a/challenge.py +++ b/challenge.py @@ -74,22 +74,23 @@ 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 + all_python_devs = filter(lambda x : x['language'] == 'python', DATA) + all_Platzi_workers = filter(lambda x : x['organization'] == 'Platzi', DATA) + adults = filter(lambda x : x['age'] > 18, DATA) + workers = list(map(lambda x: dict(x, **{'Homeless':True}) if x['organization'] == '' else dict(x, **{'Homeless':False}), DATA)) + old_people = list(map(lambda x: dict(x, **{'old':True}) if x['age'] > 30 else dict(x, **{'Old':False}), DATA)) print('Python devs: ') + for dev in all_python_devs: print(dev['name']) print('\n\n') - + print('Platzi workers: ') for worker in all_Platzi_workers: print(worker['name']) print('\n\n') - + print('Adults: ') for adult in adults: print(adult['name']) @@ -97,12 +98,11 @@ def run(): print(workers) print('\n\n') - + + print(old_people) print('\n\n') - # Remember: when possible, use lambdas - if __name__ == '__main__': run() diff --git a/lambdas.py b/lambdas.py index e931967..807e64f 100644 --- a/lambdas.py +++ b/lambdas.py @@ -1,3 +1,4 @@ + import requests import json