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
26 changes: 21 additions & 5 deletions challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,31 @@
},
]

def is_homeless(dev):
dev.update( { 'homeless': dev['organization'] == '' } )
Copy link

Choose a reason for hiding this comment

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

dev pasa por referencia, por lo que al aplicar update se modifica en DATA también. Necesitas regresar un nuevo diccionario con la modificación para no afectar tus datos de entrada.

return dev

def is_old(dev):
dev.update( { 'old': dev['age'] > 30 } )
Copy link

Choose a reason for hiding this comment

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

Aquí también deberías de hacer un nuevo diccionario.

return dev


def run():
# Using filter, generate a list with all the python devs
all_python_devs = filter(lambda dev: dev['language'] == 'python', DATA)

# Using filter, generate a list with all the Platzi workers
all_Platzi_workers = filter(lambda dev: dev['organization'] == 'Platzi', DATA)

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
# Using filter, generate a list with all people over 18 years old
adults = filter(lambda dev: dev['age'] >= 18, DATA)

# Using map, generate a new list of people with a key 'homeless' with True or False values, if 'organization' have something or not
workers = map(is_homeless , 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
old_people = map(is_old, DATA)
Copy link

Choose a reason for hiding this comment

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

Los elementos de old_people tiene la propiedad homeless por que fueron alterados antes.


print('Python devs: ')
for dev in all_python_devs:
print(dev['name'])
Expand Down