-
Notifications
You must be signed in to change notification settings - Fork 27
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
Se desarrollan funciones lamnda y se da solución al reto. #5
base: master
Are you sure you want to change the base?
Changes from all commits
f1222a0
45b20f1
3a3bbe3
3485761
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 |
---|---|---|
|
@@ -112,7 +112,7 @@ venv/ | |
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
reto07/ | ||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,35 +74,35 @@ | |
|
||
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) | ||
Comment on lines
+77
to
+79
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. Bien! |
||
workers = list(map(lambda x: dict(x, **{'Homeless':True}) if x['organization'] == '' else dict(x, **{'Homeless':False}), 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. Prioriza que tu código sea entendible sobre que sera corto. DRY! dict(x, **{'Homeless':True}) esto está dos veces, una mejora sería: list(map( lambda x: dict(x, **{'homeless': True if x['organization'] == '' else False }), DATA)) Pero no requieres el if, por que 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)) | ||
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. list(map(lambda x: dict(x, **{'old': x['age'] > 30 }), 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']) | ||
print('\n\n') | ||
|
||
print(workers) | ||
print('\n\n') | ||
|
||
|
||
|
||
print(old_people) | ||
print('\n\n') | ||
|
||
# Remember: when possible, use lambdas | ||
|
||
|
||
if __name__ == '__main__': | ||
run() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
import requests | ||
import json | ||
|
||
|
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.
Unas el nombre convencional de ENV para tu entorno, como vez está arriba ignorado.