diff --git a/challenge.py b/challenge.py index 93a85f8..8c73d3a 100644 --- a/challenge.py +++ b/challenge.py @@ -1,3 +1,5 @@ +from copy import deepcopy + DATA = [ { 'name': 'Facundo', @@ -71,14 +73,27 @@ }, ] +def worker_homeless(worker): + worker['homeless'] = worker['organization']== '' + return worker + + + +def worker_old(worker): + worker['old'] = worker['age'] > 30 + return worker + 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) # Using filter, generate a list with all the python devs + all_Platzi_workers = filter( lambda x : x['organization'] == 'Platzi', DATA) # Using filter, generate a list with all the Platzi workers + adults = filter( lambda x: x['age']> 18, DATA)# Using filter, generate a list with all people over 18 years old + workers = list(map(lambda x: dict(x, **{'Homeless': x['organization'] == ''}), DATA)) + old_people = list(map(lambda x: dict(x, **{'old':True}) if x['age'] > 30 else dict(x, **{'Old':False}), 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 print('Python devs: ') for dev in all_python_devs: @@ -104,5 +119,6 @@ def run(): # Remember: when possible, use lambdas + if __name__ == '__main__': run()