-
Notifications
You must be signed in to change notification settings - Fork 27
Challenge 07 completed #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,14 +71,31 @@ | |
| }, | ||
| ] | ||
|
|
||
| def get_homeless(d): | ||
| x = dict(d) | ||
| if (x['organization'] != ''): | ||
| x.update({'homeless': True}) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 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)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Si tu variable es |
||
| 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: | ||
|
|
@@ -101,8 +118,6 @@ def run(): | |
| print(old_people) | ||
| print('\n\n') | ||
|
|
||
| # Remember: when possible, use lambdas | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| run() | ||
There was a problem hiding this comment.
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
homelessdebería serFlase, no?