Open
Conversation
hyfi06
suggested changes
May 16, 2020
challenge.py
Outdated
| ] | ||
|
|
||
| def homeless(worker): | ||
| worker['homeless'] = True if worker['organization'] == '' else False |
There was a problem hiding this comment.
worker['organization'] == '' ya es un booleano
worker['homeless'] = worker['organization'] == ''
challenge.py
Outdated
|
|
||
| def run(): | ||
| def older_than_30(person): | ||
| person['old'] = True if person['age'] >30 else False |
There was a problem hiding this comment.
person['age'] >30 ya es booleano
person['old'] = person['age'] >30| }, | ||
| ] | ||
|
|
||
| def homeless(worker): |
There was a problem hiding this comment.
Aquí pasa pasa un diccionario por referencia, por lo que estás modificando DATA directamente. tienes que crear un nuevo diccionario y luego modificarlo.
new_worker = dict(worker)| return worker | ||
|
|
||
| def run(): | ||
| def older_than_30(person): |
There was a problem hiding this comment.
Recuerda que los diccionarios pasan por referencia. Tienes que crear uno nuevo para no modificar el original.
| all_Platzi_workers = list(filter(lambda x: x['organization']=='Platzi',DATA))# Using filter, generate a list with all the Platzi workers | ||
| adults = list(filter(lambda x: x['age']>18,DATA))# Using filter, generate a list with all people over 18 years old | ||
| workers = list(map(homeless, DATA)) # 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 = list(map(older_than_30, 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 |
There was a problem hiding this comment.
Vas a notar que al imprimir old_people tienes también la información de homeless, por que se modificó DATA en la línea anterior.
Comment on lines
+84
to
+86
| all_python_devs = list(filter(lambda x: x['language']=='python',DATA)) # Using filter, generate a list with all the python devs | ||
| all_Platzi_workers = list(filter(lambda x: x['organization']=='Platzi',DATA))# Using filter, generate a list with all the Platzi workers | ||
| adults = list(filter(lambda x: x['age']>18,DATA))# Using filter, generate a list with all people over 18 years old |
Author
Ya hice los cambios, muchas gracias! 👍 |
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.