Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,31 @@
},
]

def get_homeless(d):
x = dict(d)
if (x['organization'] != ''):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si tiene una organización no está fijo, por lo que homeless debería ser Flase, no?

x.update({'homeless': True})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x['organization'] != '' ya es booleando , pudrías usarlo directamente, sin necesidad del if

else:
x.update({'homeless': False})
return x


def get_old(d):
x = dict(d)
if (x['age'] > 30):
x.update({'old': True})
else:
x.update({'old': False})
return x


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 = list(filter(lambda data: data['language'] == 'python', DATA))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si tu variable es python_devs podrías usar ne la lambda dev en lugar de data, para darle un sentido a los elementos de DATA.

all_Platzi_workers = list(filter(lambda data: data['organization'] == 'Platzi', DATA))
adults = list(filter(lambda data: data['age'] >= 18, DATA))
workers = list(map(get_homeless, DATA))
old_people = list(map(get_old, DATA))

print('Python devs: ')
for dev in all_python_devs:
Expand All @@ -101,8 +118,6 @@ def run():
print(old_people)
print('\n\n')

# Remember: when possible, use lambdas


if __name__ == '__main__':
run()