Se desarrollan funciones lamnda y se da solución al reto.#5
Open
iraidamercedes wants to merge 4 commits intoPlatziMaster:masterfrom
Open
Se desarrollan funciones lamnda y se da solución al reto.#5iraidamercedes wants to merge 4 commits intoPlatziMaster:masterfrom
iraidamercedes wants to merge 4 commits intoPlatziMaster:masterfrom
Conversation
hyfi06
reviewed
May 16, 2020
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
| reto07/ |
There was a problem hiding this comment.
Unas el nombre convencional de ENV para tu entorno, como vez está arriba ignorado.
challenge.py
Outdated
Comment on lines
83
to
92
| ''' | ||
| def homeless(values): | ||
| if values['organization'] == '': | ||
| values['Homeless'] = True | ||
| else: | ||
| values['Homeless'] = False | ||
| return values | ||
|
|
||
| workers = list(map(homeless, DATA)) | ||
| ''' |
There was a problem hiding this comment.
Es mejor hacer un commit para guardar esto. Trata de dejar limpio tu código
challenge.py
Outdated
| old_people = list(map(lambda x: dict(x, **{'old':True}) if x['age'] > 30 else dict(x, **{'Old':False}), DATA)) | ||
|
|
||
| ''' | ||
| def homeless(values): |
There was a problem hiding this comment.
aquí pasan por referencia así que modificas directamente DATA.
challenge.py
Outdated
|
|
||
| ''' | ||
| def homeless(values): | ||
| if values['organization'] == '': |
| 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)) |
There was a problem hiding this comment.
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 x['organization'] == '' ya es booleano.
list(map( lambda x: dict(x, **{'homeless': x['organization'] == '' }), 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)) |
There was a problem hiding this comment.
list(map(lambda x: dict(x, **{'old': x['age'] > 30 }), DATA))
Comment on lines
+77
to
+79
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.