No tienes acceso a esta clase

隆Contin煤a aprendiendo! 脷nete y comienza a potenciar tu carrera

Proyecto: filtrando datos

12/21
Recursos

Aportes 825

Preguntas 67

Ordenar por:

Los aportes, preguntas y respuestas son vitales para aprender en comunidad. Reg铆strate o inicia sesi贸n para participar.

Data 猬団瑖猬

DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]

Hola,

Les comparto una alternativa al operador | para versiones de Python mayores a 3.5 pero menores a 3.9

old_people = list(map(lambda worker: {**worker, **{"old": worker["age"] > 70}}, DATA))
<h3>Fuente</h3>

https://stackoverflow.com/questions/38987/how-do-i-merge-two-dictionaries-in-a-single-expression-taking-union-of-dictiona

Un tip:
Pueden colocar DATA en un archivo aparte y luego importarlo en el archivo donde van a trabajar:

from data_filtering_db import DATA
#Con list comprehensions
adults = [worker ['name'] for worker in DATA if worker ['age'] > 18]
old_people = [{**worker, **{'old': worker['age'] > 70}} for worker in DATA]

#Con high order functions
all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))

all_platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
all_platzi_workers = list(map(lambda worker: worker['name'], all_platzi_workers))

Reto completado:

def main():
    all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
    all_platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_platzi_workers = list(map(lambda worker: worker['name'], all_platzi_workers))
    adults = [worker['name'] for worker in DATA if worker['age'] > 18]
    old_confirmation = lambda worker_age: worker_age > 70
    old_people = [worker | {'old': old_confirmation(worker['age'])} for worker in DATA]

    for worker in old_people:
        print(worker)


if __name__ == '__main__':
    main()

Proyecto de Filtrar datos

La forma en como he entendido mejor map y filter es conociendo que a cada una se le pasa una funcion especial. En otros lenguajes, como Java, cuando se utiliza la funcion Filter() se le debe de pasar un Predicate, y cuando se utiliza un Map() otra funcion como: UnaryOperator, Function, etc.

  • Predicate: Es una funcion que toma un parametro y el resultado de una comparacion.

La idea queda mas clara cuando guardo ese Predicate en una variable, usando la lambda, y otra lambda para usar mi funcion de mapeo.

  1. Version con List Comprehension:
    # Usando 'List Comprehension'
    all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"]
    label_python = "use Python - with List Comprehension"
    show_workers(all_python_devs, label_python)
  1. Version con High Order Function:
# Usando 'High Order Function'
Predicate = lambda worker : worker["language"] == "python"
all_python_devs = list(filter(Predicate, DATA))
MapFunc = lambda worker : worker["name"]
all_python_devs = list(map(MapFunc, all_python_devs))
label_python = "use Python - with High Order Functions"
show_workers(all_python_devs, label_python)

Ademas, he implementado una funcion show_workers(), para mostrar el contenido de dicha transformacion: Filtrado y mapeo:

def show_workers(workers, label=""):
    print("People who", label)
    for i, worker in enumerate(workers):
        print(f"\t{(i+1)}. {worker}")

A continuacion comparto las distintas tareas pedidas para el proyecto:

  1. Trabajadores que laboran en Platzi

    • Version con 鈥楲ist Comprehension鈥
      all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
      label_platzi = "work at Platzi - with List Comprehension"
      show_workers(all_platzi_workers, label_platzi)
      
    • Version con 鈥楬igh Order Function鈥
      # Usando 'High Order Function'
      	Predicate = lambda worker : worker["organization"] == "Platzi"
      all_platzi_workers = list(filter(Predicate, DATA))
      MapFunc = lambda worker : worker["name"]
      all_platzi_workers = list(map(MapFunc, all_platzi_workers))
      label_python = "work at Platzi - with High Order Functions"    
      show_workers(all_platzi_workers, label_python)
      
  2. Agregar la llave old a un nuevo diccionario

    • Version con 鈥楲ist Comprehension鈥
      all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
      label_platzi = "work at Platzi - with List Comprehension"
      show_workers(all_platzi_workers, label_platzi)
      
    • Version con 鈥楬igh Order Function鈥
      	#MapFunc = lambda worker : worker | {"old": worker["age"] > 70}
      MapFunc = lambda worker : {**worker, **{"old": worker["age"] > 70}}
      old_people = list(map(MapFunc, DATA))
      label_old = "is old - with High Order Functions"
      show_workers(old_people, label_old)
      

Explicacion de la llave old

Lo que en realidad hace la siguiente linea de codigo:

{**worker, **{"old": worker["age"] > 70}}

Es incrustar, pegar, agregar, la llave old en el diccionaro, pero como?:

  1. Obtenemos el diccionario, y todos sus campos en el usando {**worker}:
{'name': 'Facundo', 'age': 72, 'organization': 'Platzi', 'position': 'Technical Coach', 'language': 'python'}
  1. Obtenemos un diccionario con los campos old y su valor correspondiente, segun la condicion establecida: {**{"old": worker["age"] > 70}}
{'old': True}

Como podemos ver, la edad de Facundo es 72 anios, por esa razon su valor es True

  1. Finalmente, agregamos llave old en el diccionario de worker: {**worker, **{"old": worker["age"] > 70}}
{'name': 'Facundo', 'age': 72, 'organization': 'Platzi', 'position': 'Technical Coach', 'language': 'python', 'old': True}

Uso Ubuntu 20.04 y me daba este error:
TypeError: unsupported operand type(s) for |: 鈥榙ict鈥 and 'dict鈥
Y pues resulta que yo empec茅 ac谩 macho alfa pelo en pecho todo empoderado haciendo el curso con mi instalaci贸n por default de Python en Ubuntu 20.04 (Xubuntu, para ser m谩s preciso). Pero 隆oh sorpresa! Ubuntu 20.04 utiliza Python 3.8 y ni se te ocurra actualizarlo a 3.9 porque podr铆as romper algunos programas de Ubuntu. 驴Soluci贸n? Virtual Environments.
Y pues s铆 que se puede instalar Python 3.9 en Ubuntu 20.04, s贸lo que el int茅rprete se llama python3.9 en lugar de python3 (esto para no romper los paquetes que ya funcionan en Ubuntu hechos para la versi贸n 3.8). Para no tener que escribir Python3.9 cada vez que ejecutemos nuestro c贸digo vamos a crear un entorno virtual con el nuevo int茅rprete, una vez instalado. Para instalarlo usamos:

sudo apt install python3.9 python3.9-venv

Ya con ello nos vamos a la carpeta en la que vamos a trabajar, inicializamos git si acaso no lo hemos hecho y si no hemos iniciado antes un venv podemos iniciarlo justo como Facundo nos ense帽贸, pero usando el int茅rprete de Python 3.9:

python3.9 -m venv venv 

Peeero si est谩s como yo, que hizo todo desde antes con la versi贸n 3.8, seguro ya tienes un directorio venv que creaste usando Python 3.8. Yo decid铆 renombrarlo para no tener problemas y poder seguir usando el alias que ya hicimos clases atr谩s (o tambi茅n puedes eliminarlo para no tener que despu茅s agregar venv3.8 lo a tu .gitignore):

mv venv venv3.8 

y ahora s铆, a crear tu venv pero con el int茅rprete python3.9

python3.9 -m venv venv 

act铆valo usando el alias que hicimos en clases anteriores y listo:

avenv

Ya dentro del entorno virtual dale python3 -V y te debe de dar que est谩s usando la versi贸n 3.9 (ojo la V es may煤scula)

(venv) $ python3 -V
Python 3.9.5

La parte m谩s dif铆cil de todo esto es que, partir de ahora, cada vez que crees tu entorno virtual, no debes olvidar usar python3.9

Ya por 煤ltimo, si utilizas el botoncito de 鈥減lay鈥 de Visual Studio Code para correr tus scripts de python (yo as铆 soy de flojo), debes de cambiar el int茅rprete por default. En VS Code, presiona Ctrl+Shift+P y busca Preferences: Open User Settings
Ya estando ah铆 ahora busca python: default interpreter. Te debe de salir la ruta que es /bin/python3, simplemente c谩mbiala a /bin/python3.9 y listo.

隆Felices sesiones marat贸nicas de programaci贸n!

def run():
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA ))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

    all_platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA ))
    all_platzi_workers = list(map(lambda worker: worker["name"], all_platzi_workers))

    adults = [worker["name"] for worker in DATA if worker["age"] > 18]

    oll_people = [worker | {"oll": worker["age"] > 70} for worker in DATA]

    for worker in oll_people:
        print(worker)

if __name__ == "__main__":
    run()

Map es util cuando quiero filtar un dato de algo es lo mas parecido al list comprehension sin condicional
Filter es util cuando quiero usar un operador logico para filtar los datos

C贸digo en pares:

all_python_devs

all_python_devs = [worker["name"]
                       for worker in DATA if worker['language'] == 'python']

all_python_devs = list(
        filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))

all_platzy_workers

all_platzy_workers = [worker['name']
                          for worker in DATA if worker['organization'] == 'Platzi']

all_platzy_workers = list(
        filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_platzy_workers = list(
        map(lambda worker: worker['name'], all_platzy_workers))

adults

adults = list(filter(lambda worker: worker['age'] >= 18, DATA))
    adults = list(map(lambda worker: worker['name'], adults))

adults = [worker['name'] for worker in DATA if worker['age'] >= 18]

old_people

old_people = list(map(lambda worker: worker | {
                      'old': worker['age'] > 70}, DATA))

 old_people = [{**worker, **{'old': worker['age'] > 70}} for worker in DATA]

para recorrer cualquier variable

for worker in old_people:
        print(worker)

def challenge():
    all_python_devs = list(map(lambda worker: worker['name'], list(filter(lambda worker: worker['language'] == 'python', DATA))))

    all_platzi_workers = list(map(lambda worker: worker['name'], list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))))

    adults = [worker['name'] for worker in DATA if worker['age'] > 18]


    old_people = [{**worker, **{'old': worker['age'] > 70}} for worker in DATA]

馃懢 Completando la soluci贸n del filtrado de datos, usando filter, map y list comprehensions.

DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]


def run():
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))
    all_Platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_Platzi_workers = list(map(lambda worker: worker["name"], all_Platzi_workers))

    old_people = list(filter(lambda worker: worker["age"] > 50, DATA))
    old_people = list(map(lambda worker: worker["name"], old_people))

    adults = list(filter(lambda worker: worker["age"] > 18, DATA))
    adults = list(map(lambda worker: worker["name"], adults))

    print("- Python Developers -")
    for worker in all_python_devs:
        print(worker)

    print("\n- Platzi Workers -")
    for worker in all_Platzi_workers:
        print(worker)

    print("\n- Holds -")
    for people in old_people:
        print(people)

    print("\n- Adults -")
    for adult in adults:
        print(adult)


if __name__ == '__main__':
    run()

Uso del operador | (pipe) para unir diccionarios en Python

En la parte del primer high order function, en vez de poner solo print (worker) se puede poner print (worker [鈥榥ame鈥橾) y con eso te tira solo los nombres de los mayores de edad.

Hola compa帽eros una ayuda por favor, porque me sale el siguiente error:

TypeError: unsupported operand type(s) for |: 鈥榙ict鈥 and 鈥榙ict鈥

Mi c贸digo es el siguiente:

def run():
all_python_devs = [worker[鈥渘ame鈥漖 for worker in DATA if worker[鈥渓anguage鈥漖 == 鈥減ython鈥漖
adults = list(filter(lambda worker: worker[鈥渁ge鈥漖 > 18, DATA))
adults = list(map(lambda worker: worker[鈥渘ame鈥漖, adults))

# Agregar un diccionario al diccionario exitente con pipe |
old_people = list(map(lambda worker: worker | {"old": worker["age"] > 70}, DATA))

for worker in all_python_devs:
    print(worker)

for worker in adults:
    print(worker)

for worker in old_people:
    print(worker) 

if name == 鈥main鈥:
run()

RETO HIGH ORDER FUNCTION 鈥渁ll_python_devs鈥

    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

    print("Reto High Order Function all_python_devs")
    for worker in all_python_devs:
        print(worker)

RETO HIGH ORDER FUNCTION 鈥渁ll_Platzi_workers鈥

    all_Platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_Platzi_workers = list(map(lambda worker: worker["name"], all_Platzi_workers))

    print("Reto High Order Function all_platzi_workers")
    for worker in all_Platzi_workers:
        print(worker)

RETO LIST COMPREHENSIONS - ADULTS

    adults = [worker["name"] for worker in DATA if worker["age"] > 18]

    print("Reto list comprehension Adults")
    for worker in adults:
        print(worker)

RETO LIST COMPREHENSIONS - OLD PEOPLE

old_people = [worker | {"old": worker["age"] > 70} for worker in DATA]

print("Reto list comprehension Old_people")
for worker in old_people:
    print(worker)

Quiero compartir el reto y los ejercicios de la clase. Adem谩s hice uno de mi cuenta. Espero y sirva de ayuda.

DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]

def run(): 
    
    #list comprehension
    
    all_not_student_devs = [worker['name'] for worker in DATA if worker['position'] != 'Student']
    all_python_devs = [worker['name'] for worker in DATA if worker['language'] == 'python']
    all_platzi_workers = [worker['name'] for worker in DATA if worker['organization'] == 'Platzi']
    
    adults2 = [worker['name'] for worker in DATA if worker['age'] > 18]
    old_people2 = [worker['name'] for worker in DATA if worker['age'] > 70]
    
    #high functions
    all_python_devs2 = list(filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs2 = list(map(lambda worker: worker['name'], all_python_devs2))
    
    all_platzi_workers2 = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_platzi_workers2 = list(map(lambda worker: worker['name'], all_platzi_workers2))
    
    all_old_devs2 = list(filter(lambda worker: worker['age'] >= 20, DATA))
    all_old_devs = list(map(lambda worker: worker['name'], all_old_devs2))
    
    
    adults = list(filter(lambda worker: worker['age'] > 18, DATA))
    adults = list(map(lambda worker: worker['name'], adults))
    
    # agregar una llave y un valor al dicionario 
    old_people = list(map(lambda worker: worker | {'old': worker['age'] > 70}, DATA))
    
    
    for worker in old_people2:
        print(worker)
    


if __name__ == '__main__': 
    run()

Reto terminado. Aclaro que este s铆mbolo 鈥渱鈥 se hace con ALT + 124.

C贸digo de las funciones:

def run():
    programers = list(filter(lambda worker: worker["language"] == 'python', DATA))
    prog_name = list(map(lambda worker: worker["name"], programers))
    platzi_workers = list(map(lambda worker: worker | {"tech": worker["language"] == 'python'}, DATA))

    officials = list(filter(lambda worker: worker["organization"] == 'Platzi', DATA))
    off_name = list(map(lambda worker: worker["name"], officials))
    platzi_workers_list = list(map(lambda worker: worker | {"company": worker["organization"] == 'Platzi'}, DATA))

    adults_people = [worker['name'] for worker in DATA if worker['age'] > 17]
    old_people = [worker['name'] for worker in DATA if worker['age'] > 70]


    for worker in prog_name:
        print(f'{worker} programa en Python')
    for worker in platzi_workers:
        print(worker)
    for worker in off_name:
        print(f'{worker} trabaja en Platzi')
    for worker in platzi_workers_list:
        print(worker)
    for worker in adults_people:
        print(f'{worker} es adulto mayor de 18 a帽os')
    for worker in old_people:
        print(f'{worker} es un adulto mayor a 70')
if __name__ == '__main__':
    run()

Proyecto: filtrando datos.

  • Tenemos una lista con diccionarios sobre distintas personas. 馃憖

  • Cuando en Python colocamos una variable en may煤sculas, significa que no esperamos modificarla, esto es, es una constante 鉀.

  • El operador pipe | te permite unir un diccionario viejo con uno nuevo, y es un feature nuevo de python 3.9 馃く (sumar diccionarios).

  • Soluci贸n al reto:

    def main():
        all_python_devs = list(
            filter(lambda worker: worker['language'] == 'python', DATA))
        all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
    
        all_platzi_devs = list(
            filter(lambda worker: worker['organization'] == 'Platzi', DATA))
        all_platzi_devs = list(map(lambda worker: worker['name'], all_platzi_devs))
    
        adults = [worker['name'] for worker in DATA if worker['age'] > 18]
        old_people = [{**worker, **{'old': worker['age'] > 70}} for worker in DATA]
    
        print(all_python_devs, all_platzi_devs, adults, old_people)
    
    if __name__ == '__main__':
        main()
    

Reto completado

def run():
    
    """all_python_devs usando High Order Functions filter y map"""
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

    """all_platzi_worker usando High Order Funtions filter y map"""
    all_platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers = list(map(lambda worker: worker["name"], DATA))
    
    """adults usando list comprehensions"""
    adults =[worker["name"] for worker in DATA if worker["age"] > 18]
    
    """old people usando list comprehensions"""
    old_people = [worker | {"old": worker["age"] > 70} for worker in DATA]
    
    for worker in old_people:
        print(worker)

if __name__ == "__main__":
    run()```
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

    all_platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers = list(map(lambda worker: worker["name"], all_platzi_workers))

    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    old_people = [dict(worker, **{"old": worker["age"] > 70}) for worker in DATA ]

Tambi茅n puedes usar dictinary methods para obtener los nombres de los trabajadores sin usar map .;D

adults = list(filter(lambda worker: worker['age'] <= 18,DATA))
for person in adults:
    print(person['name'], "es un adulto")

Esta es mi solucion

#!/usr/bin/env python3
from data import DATA

def main():
    all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker['language'] == 'python', all_python_devs))

    all_platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_platzi_workers = list(map(lambda worker: worker['organization'] == 'Platzi', all_platzi_workers))

    '''
    adults = list(filter(lambda edad: edad['age'] >= 18, DATA)) 
    adults = list(map(lambda worker: worker['name'], adults)) 

    old_people = list(map(lambda worker: worker | {'old': worker['age'] > 70}, DATA))
    '''


    adults = [worker['name'] for worker in DATA if worker['age'] >= 18]

    old_people = [worker | {'old': worker['age'] > 70} for worker in DATA]

    for i in old_people:
        print(i)


if __name__ == '__main__':
    main()

def run():

print("All_python_devs")
all_python_devs = list(filter(lambda x: x["language"] == "python",DATA))
all_python_devs = list(map(lambda x : x["name"],all_python_devs))

for i in all_python_devs:
    print(i)

print("\nAll_Platzi_workers")
all_platzi_workers = list(filter(lambda x : x["organization"] == "Platzi",DATA))
all_platzi_workers = list(map(lambda x : x["name"],all_platzi_workers))

for i in all_platzi_workers:
    print(i)

print("\nAll_Adults")
all_adults = [i["name"] for i in DATA if i["age"] >= 18]
for i in all_adults:
    print(i)

print("\nOld_people")
# old_people = list(map(lambda x: x | {"old": x["age"] >= 70} , DATA))
old_people = [i | {"old": i["age"] >= 70} for i in DATA ]
print(old_people)

if name == 鈥main鈥:
run()

Hola a todos, aqu铆 esta mi soluci贸n:

    # Language
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = map(lambda worker: worker["name"], all_python_devs)

    # Platzi workers Op 1
    all_Platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_Platzi_workers = map(lambda worker: worker["name"], all_Platzi_workers)

    # Platzi workers Op 2
    all_Platzi_workers = list(map(lambda worker: worker | {"platzi_worker": worker["organization"] == "Platzi"}, DATA))
    all_Platzi_workers = list(filter(lambda worker: worker["platzi_worker"] == True, all_Platzi_workers))

    # old_people
    old_people = [ worker | {"old": worker["age"] > 70}  for worker in DATA ]

My solution to the challenge:

def run():
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))
    print(all_python_devs)
    

    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    print(adults)

    old_people = [worker | {"old": worker["age"] > 70} for worker in DATA]
    print(old_people)

    
if __name__=='__main__':
    run()

MI soluci贸n:
鈥渁ll_python_devs鈥 usando filter y map:

 all_python_devs = list(filter(lambda worker: worker["language"]  == "python", DATA)) 
    all_python_devs = list(map(lambda workers: workers["name"], all_python_devs))

鈥渁ll_Platzi_workers鈥 usando filter y map:

all_Platzi_workers = list(filter(lambda worker : worker["organization"] == "Platzi", DATA))
    all_Platzi_workers = list(map(lambda worker: worker["name"], all_Platzi_workers))

鈥渁dults鈥 usando list comprehensions:

 adults = [worker["name"] for worker in DATA if worker["age"] > 18]

鈥渙ld_people鈥 usando list comprehensions::

 old_people = [worker | {"old" :worker["age"] > 70 } for worker in DATA]

mi resultado (馃煡"TENGO EL DE OLD por si quieren saber como se hace"馃煡)

List comprehensions

#Adults
adults_2 = [worker["name"] for worker in DATA if worker["age"] > 18]

#OLD 
old_people_2 = [worker | {"old": worker["age"] > 70 } for worker in DATA]

Explicare brevemente el como hice el OLD 鈽濓笍 primero tenemos un list comprehensions llevan el valor que guardaremos ciclo tras ciclo el ciclo y por 煤ltimo la condici贸n en este caso no hay condici贸n y el ciclo de nuestro caso en particular es simple solo es for worker in DATA es decir ser铆a como un for i in range, pero en lugar del range es DATA y en lugar de i es worker pero es lo mismo luego viene lo dif铆cil lo que casi no entendemos lo primero para poder entender esto es saber que es lo que tenemos y que es lo que queremos, en primer lugar sabemos que tenemos una lista de diccionarios es decir cada elemento de la lista en lugar de ser un n煤mero o una palabra es diccionario cada elemento y como sabemos un diccionario tiene claves y valores por ejemplo 鈥渘ame鈥: 鈥淔reddy鈥 en este caso el name es la clave y freddy el valor nuestro diccionario puede tener mas y mas claves y valores entonces cada diccionario es apenas un elemento de la lista es como una monstruosidad 驴no?, en segundo lugar queremos que a cada diccionario se le agregue una clave y un valor mas es decir un 鈥渙ld鈥 : True
la clave que queremos agregar es 鈥渙ld鈥 y sus valores ser谩n True o False ser谩 True si la persona tiene m谩s de 70 a帽os y false si tiene menos de eso, sabiendo que queremos y que tenemos pasemos al c贸digo ya sabemos que el for lo que har谩 es pasar una vez por cada uno de los diccionarios de la lista lo que le tenemos que decir o lo que nos falta decirle es que queremos que haga cuando pase por cada uno de los diccionarios y lo que queremos es agregar old y evaluar si es true o false entonces nuestra variable worker que tambi茅n podr铆a ser la letra 鈥渋鈥 de toda la vida al momento de pasar por los diccionarios su valor va a ser un diccionario por lo tanto tenemos que encontrar la forma de agregar claves al diccionario, pero al menos yo no encontr茅 como hacerlo de una forma sencilla as铆 que , al menos la soluci贸n m谩s f谩cil que yo encontr茅 fue convertir la clave 鈥渙ld鈥 en un diccionario as铆 es esta clave sola ser铆a un diccionario y esto lo hacemos poniendolo entre llaves as铆 {鈥渙ld鈥:True} y para saber si es False o true tenemos que utilizarla edad de la persona del diccionario que se encuentra en 鈥渁ge鈥 por lo tanto usamos worker[鈥渁ge鈥漖 o i[鈥渁ge鈥漖 si estas utilizando i en lugar de worker y como lo que dijimos era que si es mayor de 70 el valor old sera true entonces lo podemos compara de esta manera worker[鈥渁ge鈥漖 > 70 recordemos que worker[鈥渁ge鈥漖 representa la edad o es la edad para convertir entonces old en un diccionario quedaria as铆 {鈥渙ld鈥: worker[鈥渁ge鈥漖 > 70 } de esta manera nuestro diccionario dice lo siguiente para el diccionario actual si la edad es menor de 70 no es viejo u old es false y si es mayor de 70 es viejo u old es True ahora solo flata agregarlo a el diccionario actual por el que esta pasando nuestro cilo podemos sumar clos diccionarios con este simbolo 鈥渱鈥 quedando as铆 la sentencia work | {鈥渙ld鈥: worker[鈥渁ge鈥漖 > 17} ahora cada vez que nuestro ciclo pase por un diccionario lo que va a hacer es evaluar si old es true o false y agregarlo quedando nuestro list comprehensions asi [workwer | {鈥渙ld鈥: workwer[鈥渁ge鈥漖 > 17 for worker in DATA]

Si llegaste hasta aqu铆 gracias por leerlo todo !

Filter Map

# Python Devs
all_python_devs_= list(filter(lambda worker : worker["language"] == 'python', DATA))
    all_python_devs = list(map(lambda worker : worker["name"], all_python_devs_2))


#Platzi Workers
all_platzi_workers = list(filter(lambda worker : worker["organization"] == 'Platzi', DATA))
all_platzi_workers = list(map(lambda worker : worker["name"], all_platzi_workers_2))

Codigo Organizado

#============================
    #   Python_devs and Platzi workers
    #============================
    #List Comprehension 
    all_python_devs = list([worker["name"] for worker in DATA if worker["language"] == "python"])
    all_Platzi_devs = list([worker["name"] for worker in DATA if worker["organization"] == "Platzi"])

    print ("********************** List Comprehension **********************")
    print ("* Python_devs *")
    print (all_python_devs)

    print (" * Platzi_devs *")
    print (all_Platzi_devs)

    print ("---------------------------------------------------------")
    #Filter Maps
    all_python_devs_filter = list(filter(lambda worker: worker["language"] == "python", DATA ))
    all_python_devs_map = list(map(lambda worker: worker["name"], all_python_devs_filter ))

    all_Platzi_devs_filter = list(filter(lambda worker:worker["organization"] == "Platzi",DATA))
    all_Platzi_devs_map = list(map(lambda worker: worker["name"],all_Platzi_devs_filter))

    print ("********************** Filter Maps **********************")
    print ("* Python_devs *")
    print (all_python_devs_map)

    print (" * Platzi_devs *")
    print (all_Platzi_devs_map)


    #============================
    #   Old people and adults
    #============================

    #List Comprehension 

    old_people_comprehension = list([worker["name"] for worker in DATA if worker["age"] > 70])
    all_adults_devs = list([worker["name"] for worker in DATA if worker["age"] >=  18])

    print ("********************** List Comprehension **********************")
    print ("* Old people *")
    print (old_people_comprehension)

    print ("* Adults *")
    print (all_adults_devs)

    #Filter Maps
    old_people = list(map(lambda worker: worker | {"old": worker["age"] >70},DATA))
    all_adults_devs = list(filter(lambda worker: worker["age"] >= 18,DATA))
    all_adults_devs_map = list(map(lambda worker: worker["name"] ,all_adults_devs))


    print ("********************** Filter Maps **********************")
    print ("* Old people *")
    print (old_people)

    print ("* Adults *")
    print (all_adults_devs_map)
    all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
    all_platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_platzi_workers = list(map(lambda worker: worker['name'], all_platzi_workers))
    adults = [worker['name'] for worker in DATA if worker['age'] > 18]
    old_people = [worker | {'old': worker['age']} for worker in DATA if worker['age'] > 70]
    old_people = [worker['name'] for worker in old_people]
    for workers in old_people:
        print(workers)

As铆 resolv铆 el reto:

DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]


def run():
    #Examples class

    #all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"]
    #all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
    #adults = list(filter(lambda worker: worker["age"] >18, DATA))
    # adults = list(map(lambda worker: worker["name"], adults))
    # old_people = list(map(lambda worker: worker | {"old":worker["age"] > 70}, DATA))

    # Reto
    all_python_devs = list(
        filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

    all_platzi_workers = list(
        filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers = list(
        map(lambda worker: worker["name"], all_platzi_workers))

    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    old_people = [worker | {"old": worker["age"] > 70} for worker in DATA]

    #Result 
    print("\n** For all python devs **")
    for worker in all_python_devs:
        print(worker)

    print("\n** For all Platzi workers **")
    for worker in all_platzi_workers:
        print(worker)

    print("\n** For old people **")
    for worker in adults:
        print(worker)

    print("\n** For adults **")
    for worker in old_people:
        print(worker)


if __name__ == '__main__':
    run()

Para correrlo utilic茅 la versi贸n 3.9 de Python

$ python3.9 filter_data.py
** For all python devs **
Facundo
Karo
Pablo
Lorena

** For all Platzi workers **
Facundo
H茅ctor
Gabriel
Isabella

** For old people **
Facundo
Luisana
H茅ctor
Gabriel
Isabella
Karo
Ariel
Pablo
Lorena

** For adults **
{'name': 'Facundo', 'age': 72, 'organization': 'Platzi', 'position': 'Technical Coach', 'language': 'python', 'old': True}
{'name': 'Luisana', 'age': 33, 'organization': 'Globant', 'position': 'UX Designer', 'language': 'javascript', 'old': False}
{'name': 'H茅ctor', 'age': 19, 'organization': 'Platzi', 'position': 'Associate', 'language': 'ruby', 'old': False}
{'name': 'Gabriel', 'age': 20, 'organization': 'Platzi', 'position': 'Associate', 'language': 'javascript', 'old': False}
{'name': 'Isabella', 'age': 30, 'organization': 'Platzi', 'position': 'QA Manager', 'language': 'java', 'old': False}
{'name': 'Karo', 'age': 23, 'organization': 'Everis', 'position': 'Backend Developer', 'language': 'python', 'old': False}
{'name': 'Ariel', 'age': 32, 'organization': 'Rappi', 'position': 'Support', 'language': '', 'old': False}
{'name': 'Juan', 'age': 17, 'organization': '', 'position': 'Student', 'language': 'go', 'old': False}
{'name': 'Pablo', 'age': 32, 'organization': 'Master', 'position': 'Human Resources Manager', 'language': 'python', 'old': False}
{'name': 'Lorena', 'age': 56, 'organization': 'Python Organization', 'position': 'Language Maker', 'language': 'python', 'old': False} 

El s铆mbolo 鈥渱鈥 conocido como 鈥減ipe鈥 es un nuevo feature de Python >3.9 en el cual puedas juntar dos diccionarios.

data = list(map(lambda elemento: elemento | {"nueva_llave": "nuevo_valor"}, iterable))

Vengo de javascript y la verdad que estaba acostumbrado a combinar map y filter en una misma l铆nea de forma f谩cil. Hacer esto en python lo veo m谩s complicado, pero qued茅 enamorado de los list comprenhensions que me solucionan lo anterior 馃榿

Mi soluci贸n:

all_python_devs = list(map(lambda el1: el1["name"], filter(
        lambda el2: el2["language"] == "python", DATA)))

all_platzi_workers = list(map(lambda el1: el1["name"], filter(
        lambda el2: el2["organization"] == "Platzi", DATA)))

adults = [worker["name"] for worker in DATA if worker['age'] > 18]

old_people = [worker | {"old": worker["age"] > 70} for worker in DATA]

Reto aceptado y realizado. Aunque no comprendo bien como funciona la list comprehensions en el caso de la lista old_people.
def run():
os.system(鈥渃ls鈥)
#
all_python_devs = list(filter(lambda worker: worker[鈥渓anguage鈥漖==鈥減ython鈥,DATA))
all_python_devs = list(map(lambda worker: worker[鈥渘ame鈥漖, all_python_devs))
all_platzi_workers = list(filter(lambda worker: worker[鈥渙rganization鈥漖 == 鈥淧latzi鈥, DATA))
all_platzi_workers = list(map(lambda worker: worker[鈥渘ame鈥漖, all_platzi_workers))
adults = [worker[鈥渘ame鈥漖 for worker in DATA if worker[鈥渁ge鈥漖 > 18]
old_people = [{**worker, **{鈥渙ld鈥: worker[鈥渁ge鈥漖 > 70}} for worker in DATA]
#
print(鈥淒esarrolladores de Python:鈥)
for worker in all_python_devs:
print(worker)
print("")
print(鈥淭rabajadores de Platzi:鈥)
for worker in all_platzi_workers:
print(worker)
print("")
print(鈥淢ayores de 18 a帽os:鈥)
for worker in adults:
print(worker)
print("")
print(鈥淎帽adir nueva llave (old:) al diccionario para aquellos mayores de 70 con true o false鈥)
for worker in old_people:
print(worker)

if name == 鈥main鈥:
run()

Reto

def run():

    # Comprehensions solutions
    #all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"]
    all_python_devs =list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs=list(map(lambda worker: worker["name"],all_python_devs))

    #all_Platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
    all_Platzi_workers = list(map(lambda worker: worker | {"work_platzi": worker["organization"] =="Platzi"}, DATA))

    #adults =  [worker["name"] for worker in DATA if worker["age"] > 18]
    #adults = list(filter(lambda worker: worker["age"] > 18, DATA))
    #adults = list(map(lambda worker: worker["name"], adults))
    adults = [worker["name"] for worker in DATA if worker["age"] > 18]

    
    #old_people = list(map(lambda worker: worker | {"old": worker["age"] > 70}, DATA))
    old_people =[worker["name"] for worker in DATA if worker["age"]> 70]


    print("Trabajadores que su lenguaje es Python")
    print("-------------------------------------")
    print("")
    for worker in all_python_devs:
        print(worker)

    print("")
    print("")
    print("Trabajadores de Platzi")
    print("-------------------------------------")
    print("")
    for worker in all_Platzi_workers:
        print(worker)

    print("")
    print("")
    print("Trabajadores Adultos")
    print("-------------------------------------")
    print("")
    for worker in adults:
        print(worker)

    print("")
    print("")
    print("Trabajadores Viejitos")
    print("-------------------------------------")
    print("")
    for worker in old_people:
        print(worker)

if __name__ == '__main__':
    run()

Para las list y dict comprenhensions encerrarlas en los corchetes cuadrados ([list comprenhension]) es equivalente a encerrarla en la funci贸n list(list comprenhension) y de forma hom贸loga encerrar la dict comprenhension en ({ dict comprenhension }) es equivalente a encerararla en la funci贸n dict( dict comprenhension ), por si hay alguien al que se le dificulte entender esto, estos s铆mbolos que las encierran son para declarar una lista o un diccionario.

def filter_python():
    python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    for worker in python_devs:
        print(worker["name"])
def comprehension_adults():
    adults = [worker["name"] for worker in DATA if worker["age"] >= 18]
  for worker in adults:
        print(worker)
#all_pyhton_devs con HOF
    all_pyhton_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_pyhton_devs = list(map(lambda worker: worker["name"] , all_pyhton_devs))
#all_platzi_workers con HOF 
    all_pyhton_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_pyhton_workers = list(map(lambda worker: worker["name"], all_pyhton_workers))
#old_people list comprehemsion
    old_people = [worker | {"old": worker["age"] > 70} for worker in DATA]
#adults list comprehension
    adults = [worker["name"] for worker in DATA if worker["age"] > 18

Este es el c贸digo que realice para resolver el reto que nos propuso el profesor

def run():
    # all_python_devs = [worker["name"] for worker in DATA if worker['language'] == 'python']
    all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
    # all_Platzi_workers = [worker["name"] for worker in DATA if worker['organization'] == 'Platzi']
    all_Platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_Platzi_workers = list(map(lambda worker: worker['name'], all_Platzi_workers))
    # adults = list(filter(lambda worker: worker['age'] > 18, DATA))
    # adults = list(map(lambda worker: worker['name'], adults))
    adults = [worker['name'] for worker in DATA if worker['age'] > 18]
    # old_people = list(map(lambda worker: worker | {'old': worker['age'] > 70} , DATA))
    old_people = [worker['name'] for worker in DATA if worker['age'] > 70]

    for worker in old_people:
        print(worker)


if __name__ == '__main__':
    run()

Hola, les comparto mi versi贸n tratando de hacer el c贸digo mas legible:

    python_devs = lambda worker: worker["language"] == "python"
    only_name = lambda worker : worker["name"]
    all_python_devs = list(map(only_name, filter(python_devs, DATA)))

    Platzi_workers = lambda worker: worker["organization"] == "Platzi"
    all_Platzi_workers = list(map(only_name, filter(Platzi_workers, DATA)))

    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    old_people = [worker | { "old": worker["age"] > 70} for worker in DATA]
 

Les comparto la soluci贸n del reto

def run():
    
    all_python_devs = list(filter(lambda worker: worker["language"] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))
    
    all_platzi_devs = list(filter(lambda worker: worker["organization"] == 'Rappi', DATA))
    all_platzi_devs = list(map(lambda worker: worker["name"], all_platzi_devs))
    
    adults = [worker["name"] for worker in DATA if worker["age"] > 30 ]
    old_people = [worker | {"old": "TRUE"} for worker in DATA if worker["age"] > 30 ]
    
    for worker in old_people:
        print(worker)






if __name__ == '__main__':
    run()

Y les comparto las notas de la clase:

def run ():
    all_python_devs = [worker["name"] for worker in DATA if worker["language"] == 'python']  ## hacer una lista de un dictionario de trabajadores que usen python usando list comprehension.
    all_platzi_devs = [worker["name"] for worker in DATA if worker["organization"] == 'Platzi'] ## lo mismo de arriba pero con trabajadores de Platzi
    
    adults = list(filter(lambda worker: worker["age"] > 30, DATA))
    ## con esta high order function lo que estoy haciendo es hacer una lista con filter de cada worker = (es cada diccionario en DATA):
    ## si cumple la condici贸n del iterable Data. "worker" va hacer referencia de cada diccionario de mi diccionario anidado. Filter compara la iteraci贸n true or false.
    
    adults = list(map(lambda worker:  worker["name"], adults))
    ## Aqu铆 solo necesito traerme el nombre, entonces sobreescribo la variable con map que lo que hace en la funci贸n lambda es traerme la expressi贸n y a comparaci贸n de filter
    ## filter que solo comopara la expressi贸n en true or false. entonces en este caso pues me trae solo el worker["name"]
    
    old_people = list(map(lambda worker: worker | {"old": worker["age"] > 30}, DATA))
    ## Aqu铆 lo que estamos haciendo es que con una high order function aadimos nueva informacin al diccionario apartir de el retorno de una funcin lambda (y map)
    ## por lo cual para cada worker (diccionario en DATA): a worker (cada diccionario)  |  (simbolo PIPE --> esto es adicionarle otra llave al diccionario)(para a帽dir listas es un +)
    ## abro llaves {"coloco el nombre de la nueva llave": y para cada llave de cada diccionario (worker) se guarde la operaci贸n realizada}, de DATA.
    ##
    
    
    for worker in old_people:
        print(worker)



if __name__ == '__main__':
    run()

Comparto mis apuntes de la clase:

Les dejo mi soluci贸n al reto!

def run():
    #Print all python devs
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs_names = map(lambda worker: worker["name"], all_python_devs)
    print("\nPYTHON DEVS")
    for employee in all_python_devs_names:
        print(employee)

    #Print all platzi workers
    all_platzi_worker = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_worker_names = list(map(lambda worker: worker["name"], all_platzi_worker))
    print("\nPLATZI WORKERS")
    for employee in all_platzi_worker_names:
        print(employee)
    
    #Print all the adults using list comprehension
    adults = [worker["name"] for worker in DATA if worker["age"]>=18]
    print("\nAdults")
    for worker in adults:
        print(worker)
    
    #Add a new value named "old" in each dictionary
    #| pipe operator used to join dictionaries (in a list we join use '+')
    old_people = [worker | {"old": worker["age"] >= 70} for worker in DATA]
    print("\nOld People confirmation")
    for worker in old_people:
        print(worker["name"], worker["age"] , worker["old"])

if __name__ == "__main__":
    run()

Mi respuesta al reto:

DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]


def run():
    all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
    all_platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_platzi_workers = list(map(lambda worker: worker['name'], all_platzi_workers))
    adults = [worker['name'] for worker in DATA if worker['age'] >= 18]
    old_people = [{**worker, **{'old': worker['age'] > 70}} for worker in DATA]
    

    for worker in old_people:
        print(worker)

if __name__ == '__main__':
    run()

RETO COMPLETADO

def run():
    # all_devs_python = [worker["name"] for worker in DATA if worker["language"] == "python"]
    alldevs = list(filter(lambda worker: worker["language"] == "python", DATA))
    alldevs = list(map(lambda worker: worker["name"], alldevs))
    # all_Platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
    allplatzi = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    allplatzi = list(map(lambda worker: worker["name"], allplatzi))
    # adults = list(filter(lambda worker: worker["age"] > 18, DATA)) 
    # adults = list(map(lambda worker: worker["name"], adults))
    all_adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    # old_people = list(map(lambda worker: worker | {"old": worker["age"] > 70}, DATA))
    old_people = [worker["name"] for worker in DATA if worker["age"] > 70]

    for worker in alldevs:
        print(worker)
    for worker in allplatzi:
        print(worker)
    for worker in all_adults:
        print(worker)
    for worker in old_people: 
        print(worker)
    
if __name__ == "__main__":
    run()

La primera vez que intent茅 el reto, no lo logr茅 y me estres茅. La segunda vez, repet铆 todas las clases y tampoco logr茅. Finalmente me fui a dormir y al dia siguiente lo logr茅 sin problemas
Recomendaci贸m: No te presiones si en los primeros intentos no te funciona, simplemente date t煤 tiempo

Comprehensions solutions

#all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"]

all_python_devs = list(filter(lambda worker:worker["language"] == "python",DATA))
all_python_devs = list(map(lambda worker:worker["name"],all_python_devs))

#all_Platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]

all_Platzi_workers = list(filter(lambda worker:worker["organization"] == "Platzi",DATA))
all_Platzi_workers = list(map(lambda worker:worker["name"],all_Platzi_workers))

#adults = list(filter(lambda worker:worker["age"] > 18, DATA))
#adults = list(map(lambda worker:worker["name"],adults))

adults =  [worker["name"] for worker in DATA if worker["age"] > 18]

#old_people = list(map(lambda worker: worker | {"old": worker["age"] > 70}, DATA))

old_people_mayor = [worker | {"old": "true"}  for worker in DATA if worker["age"] > 70 ]
old_people_menor = [worker | {"old": "false"}  for worker in DATA if worker["age"] < 70 ]

old_people = old_people_mayor + old_people_menor
  • solucion al reto de la clase
from concurrent.futures.thread import _worker


DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]
def main():
    all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
    all_platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_platzi_workers = list(map(lambda worker: worker['name'], all_platzi_workers))
    adults = [worker['name'] for worker in DATA if worker['age'] > 18]
    old_confirmation = lambda worker_age: worker_age > 70
    old_people = [worker | {'old': old_confirmation(worker['age'])} for worker in DATA]

    for worker in old_people:
        print(worker)


if __name__ == '__main__':
    main()

Reto cumplido:

# Importe la lista con los datos para que estuviera m谩s limpio el c贸digo
<from data_worker import DATA

def run():
    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_Platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_Platzi_workers = list(map(lambda worker: worker["name"], all_Platzi_workers))
    for worker in all_python_devs:
        print(worker)
    

if __name__ == "__main__":
    run()> 

RETO:

#Completo
all_python_devs = list(filter(lambda worker: worker['language'] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
    
    all_Platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_Platzi_workers = list(map(lambda worker: worker['name'], all_Platzi_workers))
    
    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    old_people = [{**worker, **{'old': worker['age'] > 70}} for worker in DATA]
    
    for worker in old_people:
        print(worker)
        
<code> 

problemas por tener un python desactualizado en tu venv ?
En mi caso tengo WSL2 con ubuntu 20.0.4 con python 3.8.1 por lo cual no pod铆a ejecutar el comando 鈥渄ict_1 | dict_2 鈥 que solo est谩 disponible para python 3.9 as铆 que para actualizar el python de mi ambiente virtual de venv tuve que actualizar el de todo mi ubuntu (SO) siguiendo el tutorial de la siguiente p谩gina y si funciono.
https://cloudbytes.dev/snippets/upgrade-python-to-latest-version-on-ubuntu-linux

Hola, esta fue mi soluci贸n a los retos:

#RETOS FINALES

    #1. Crear la lista all_python_devs usando filter() y map()

    all_python_devs_reto = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs_reto = list(map(lambda worker: worker["name"], all_python_devs_reto))
    print(f'Los desarrolladores de python son: {all_python_devs_reto}')

    #2. Crear la lista all_Platzi_workers usando filter() y map()

    all_platzi_workers_reto = list(filter( lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers_reto = list(map(lambda worker: worker["name"], all_platzi_workers_reto))
    print(f'Los trabajadores en platzi son: {all_platzi_workers_reto}')

    #3 Crear la lista old_people con list comprehensions

    old_people_reto = list(worker | {"old": worker["age"] >=30 } for worker in DATA)
    print(f'El nuevo diccionario es {old_people_reto}')

    #4 Crear la lista adults con list comprehensions

    adults_reto = list(worker["name"] for worker in DATA if worker["age"] >= 18)
    print(f'Los miembros del equipo que ya cumplieron la mayoria de edad son: {adults_reto}')

Aqui tarea aunque admito que en este caso en particular siento que el codigo es mucho menos entendible a la hora de leerlo, y al trabajar debemos realizar codigo que sean facil de leer y entener por nuestos co worker

def run():

	all_pythondevs = list(filter(lambda worker: worker["language"]== "python", DATA))

		all_pythondevs =list(map(lambda worker:worker["name"], all_pythondevs))

		all_platziworker = list(filter(lambda worker:worker["organization"]== "Platzi",DATA))

		all_platziworker =list(map(lambda worker:worker["name"],all_platziworker))

		adults = list(filter(lambda worker: worker["age"]>=18, DATA ))

		adults = list(map(lambda worker:worker["name"], ad

DATA = [
{
鈥榥ame鈥: 鈥楩acundo鈥,
鈥榓ge鈥: 72,
鈥榦rganization鈥: 鈥楶latzi鈥,
鈥榩osition鈥: 鈥楾echnical Coach鈥,
鈥榣anguage鈥: 鈥榩ython鈥,
},
{
鈥榥ame鈥: 鈥楲uisana鈥,
鈥榓ge鈥: 33,
鈥榦rganization鈥: 鈥楪lobant鈥,
鈥榩osition鈥: 鈥楿X Designer鈥,
鈥榣anguage鈥: 鈥榡avascript鈥,
},
{
鈥榥ame鈥: 鈥楬茅ctor鈥,
鈥榓ge鈥: 19,
鈥榦rganization鈥: 鈥楶latzi鈥,
鈥榩osition鈥: 鈥楢ssociate鈥,
鈥榣anguage鈥: 鈥榬uby鈥,
},
{
鈥榥ame鈥: 鈥楪abriel鈥,
鈥榓ge鈥: 20,
鈥榦rganization鈥: 鈥楶latzi鈥,
鈥榩osition鈥: 鈥楢ssociate鈥,
鈥榣anguage鈥: 鈥榡avascript鈥,
},
{
鈥榥ame鈥: 鈥業sabella鈥,
鈥榓ge鈥: 30,
鈥榦rganization鈥: 鈥楶latzi鈥,
鈥榩osition鈥: 鈥楺A Manager鈥,
鈥榣anguage鈥: 鈥榡ava鈥,
},
{
鈥榥ame鈥: 鈥楰aro鈥,
鈥榓ge鈥: 23,
鈥榦rganization鈥: 鈥楨veris鈥,
鈥榩osition鈥: 鈥楤ackend Developer鈥,
鈥榣anguage鈥: 鈥榩ython鈥,
},
{
鈥榥ame鈥: 鈥楢riel鈥,
鈥榓ge鈥: 32,
鈥榦rganization鈥: 鈥楻appi鈥,
鈥榩osition鈥: 鈥楽upport鈥,
鈥榣anguage鈥: 鈥樷,
},
{
鈥榥ame鈥: 鈥楯uan鈥,
鈥榓ge鈥: 17,
鈥榦rganization鈥: 鈥樷,
鈥榩osition鈥: 鈥楽tudent鈥,
鈥榣anguage鈥: 鈥榞o鈥,
},
{
鈥榥ame鈥: 鈥楶ablo鈥,
鈥榓ge鈥: 32,
鈥榦rganization鈥: 鈥楳aster鈥,
鈥榩osition鈥: 鈥楬uman Resources Manager鈥,
鈥榣anguage鈥: 鈥榩ython鈥,
},
{
鈥榥ame鈥: 鈥楲orena鈥,
鈥榓ge鈥: 56,
鈥榦rganization鈥: 鈥楶ython Organization鈥,
鈥榩osition鈥: 鈥楲anguage Maker鈥,
鈥榣anguage鈥: 鈥榩ython鈥,
},
]

def run():
all_python_devs = [objeto[鈥渘ame鈥漖 for objeto in DATA if objeto[鈥渓anguage鈥漖 == 鈥減ython鈥漖
all_platzi_workers = [worker[鈥渘ame鈥漖 for worker in DATA if worker[鈥渙rganization鈥漖 == 鈥淧latzi鈥漖

workers = list(filter(lambda objeto: objeto[鈥渓anguage鈥漖 == 鈥減ython鈥, DATA))
workers = list (map(lambda objeto: objeto[鈥渘ame鈥漖, workers))

workerss = list(filter(lambda objeto: objeto [鈥渙rganization鈥漖 == 鈥淧latzi鈥, DATA))
workerss = list(map(lambda objeto: objeto[鈥渘ame鈥漖, workerss))

adults = list(filter(lambda objeto: objeto[鈥渁ge鈥漖 > 18 , DATA) )
adults = list(map(lambda objeto: objeto[鈥渘ame鈥漖, adults))

adultos = [objeto[鈥渘ame鈥漖 for objeto in DATA if objeto[鈥渁ge鈥漖 >= 18]

#for objeto in all_python_devs:

print(objeto)

#for objeto in all_platzi_workers:

print(objeto)

for objeto in adultos:
print(objeto)

if name ==鈥main鈥:
run()

Vale la pena aclarar que en el de old_people, lo que se est谩 modificando en la comprehension list es el primer elemento, por eso el operador pipe | es utilizado en el primer elemento, antes del iterador. No hay necesidad de condicional porque no se est谩 filtrando, solo mapeando, Hagan de cuenta que MAPEAR es modificar el elemento en la primera instrucci贸n del comprehensive, y FILTRAR es el condicional

all_python_devs = [worker['name'] for worker in DATA if worker['language'] == 'python']
    all_python_devs_filter = list(filter(lambda worker : worker["language"] == 'python', DATA))
    all_python_devs_map = list(map(lambda worker : worker["name"] ,all_python_devs_filter))

    if all_python_devs == all_python_devs_map:
        print("DONE")

    all_platzi_workers = [worker['name'] for worker in DATA if worker['organization'] == 'Platzi']
    all_platzi_workers_filter = list(filter(lambda worker : worker['organization'] == 'Platzi' ,DATA))
    all_platzi_workers_map = list(map(lambda worker : worker["name"] ,all_platzi_workers_filter))
    
    if all_platzi_workers == all_platzi_workers_map:
        print("DONE")

    adults = list(filter(lambda worker: worker['age'] > 18, DATA))
    adults = list(map(lambda worker: worker["name"], adults))

    adults_comprehension = [worker['name'] for worker in DATA if worker["age"] > 18]
    
    if adults == adults_comprehension:
        print("DONE")

    old_people = list(map(lambda worker: worker | {"old": worker['age'] > 70}, DATA))
    old_people_comprehension = [worker | {'old' : worker['age'] > 70} for worker in DATA]
    if old_people == old_people_comprehension:
        print("DONE")
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

    all_Platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_Platzi_workers = list(map(lambda worker: worker["name"], all_Platzi_workers)) 

    adults =  [worker["name"] for worker in DATA if worker["age"]>18]
    old_people = [{**worker, **{'old': worker['age'] > 70}} for worker in DATA]

Aqui mi aportacion al reto en Python 3.9, convertir lo de los pips fue complejo para ello tuve que leer los comentarios, pero basicamente es usar la base de lo que nos muestran en clase y usar el ciclo for al final.

def run():
    all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"]
    all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
    adults = list(filter(lambda age: age["age"] > 18,DATA))
    adults = list(map(lambda worker: worker["name"], adults))

    old_people = list(map(lambda worker: worker | {"old": worker["age"] > 70}, DATA))
    # el pipe | aqui nos permite unir un proceso con otro, en este caso una lista con otra.
    # solo funciona en python 3.9 en adelante
    #for worker in old_people:
    #    print(worker)

    # Inversio a las funciones anteriores
    fos_python_devs = list(filter(lambda pydev: pydev["language"] == "python",DATA))
    fos_python_devs_names = list(map(lambda name: name["name"], fos_python_devs))

    fos_platzi_workers = list(filter(lambda plat_worker: plat_worker["organization"] == "Platzi", DATA))
    fos_platzi_workers_names = list(map(lambda name: name["name"], fos_platzi_workers))

    comprehension_adults = [adult["name"] for adult in DATA if adult["age"] > 18]
    comprehension_old_people = [old | {"old": old["age"] > 70 } for old in DATA]
    for age in comprehension_old_people:
        print(age)

if __name__ == '__main__':
    run()

def run():
all_python_devs2 = list(map(lambda worker: worker [鈥渘ame鈥漖,
all_python_devs2))
all_platzi_workers2 = list(filter(lambda worker: worker
[鈥渙rganization鈥漖 == 鈥淧latzi鈥 , DATA))
all_platzi_workers2 = list(map(lambda worker: worker[鈥渘ame鈥漖,
all_platzi_workers2))

for worker in all_platzi_workers2:
print(worker)

if name == 鈥main鈥:
run()

Reto completado 馃槂 馃煝

		# list comprehensions
    all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"]
    #filter y map
    all_python_devs2 = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs2 = list(map(lambda worker: worker["name"], all_python_devs2))

    # list comprehensions
    all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
    #filter y map
    all_platzi_workers2 = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers2 = list(map(lambda worker: worker["name"], all_platzi_workers2))

    #filter y map
    adults = list(filter(lambda worker: worker["age"] > 18, DATA))
    adults = list(map(lambda worker: worker["name"], adults))
    # list comprehensions
    adults2 = [worker["name"] for worker in DATA if worker["age"] > 18]

    #filter y map
    old_people = list(map(lambda worker: worker | {"old": worker["age"] > 70}, DATA))
    # list comprehensions
    old_confirmation = lambda worker_age: worker_age > 70
    old_people2 = [worker | {'old': old_confirmation(worker['age'])} for worker in DATA]

    for worker in old_people:
        print(worker)```

min 8:18
solo agrega: 'name como 铆ndice de worker y no es necesario usar la funcion de o. s. map.

for worker in adults:
print(worker[鈥榥ame鈥橾

Est谩 bien que el profe te haga usar map como ejercicio pero como vimos no es necesario.

comparto mi codigo del desafio:

    #using hight functions
    all_python_devs= [worker["name"] for worker in DATA if worker["language"] == "python"]
    #using list comprenhension
    language1= list(filter(lambda worker: worker["language"] == "python", DATA ))
    language1= list(map(lambda worker: worker["name"], language1))

    #using hight functions
    all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
    #using list comprenhension
    organization1= list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    organization1= list(map(lambda worker: worker["name"], organization1))


    #using list comprenhension
    adults = list(filter(lambda worker: worker["age"] > 18, DATA))
    #keep only the name with map fuction
    adults = list(map(lambda worker: worker["name"], adults))
    #using hight functions
    all_adults_workers= [worker["name"] for worker in DATA if worker["age"] > 18]



    #create new valor old_people
    old_people= list(map(lambda worker: worker | {"old": worker["age"] > 70}, DATA))


    # for worker in all_python_devs:
    #     print("python: ", worker)
        
    # for worker in all_platzi_workers:
    #     print("platzi: ", worker)

    # for worker in adults:
    #     print(">18: ", worker)

    for worker in language1:
        print("python: ", worker)

    for worker in organization1:
        print("platzi: ", worker)

    for worker in all_adults_workers:
        print("adults: ", worker)


Mis respuestas
1)

<
all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
> 
<
all_platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
all_platzi_workers = list(map(lambda worker: worker['name'], all_platzi_workers))
> 
<
adults = [worker for worker in DATA if worker['age']>18]

for worker in adults:
        print(worker['name'])
> 
<
old_people = [worker for worker in DATA if worker['age']>70]

for worker in old_people:
print(worker['name'])
> 

Lo hice de esta manera 馃槃

def run():

    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))
    
    all_platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers = list(map(lambda worker: worker["name"], all_platzi_workers))

    
    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    
    old_people = [worker | {"old": True} if worker["age"] > 70 else worker | {"old": False} for worker in DATA]

    for worker in old_people:
        print(worker)


if __name__ == '__main__':
    run()
DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': 'Globant',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]

def run():
    all_python_dev = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_dev = list(map(lambda worker: worker["name"], all_python_dev))
    
    all_globant_workers = list(filter(lambda worker: worker["organization"] == "Globant", DATA))
    all_globant_workers = list(map(lambda worker: worker["name"], all_globant_workers))
    
    adults = [worker["name"] for worker in DATA if worker["age"] > 20]
    
    old_worker = [worker["name"] for worker in DATA if worker["age"] > 69]
    
    # for worker in all_python_dev:
    #         print(worker)
    
    # for worker in all_globant_workers:
    #     print(worker)
    
    # for worker in adults:
    #     print(worker)
    
    for worker in old_worker:
        print(worker)



if __name__ == '__main__':
    run()

mi aporte

#all_python_devs
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA ))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))
#all_platzi_workers
    all_platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers = list(map(lambda worker: worker["name"], all_platzi_workers))
#adults
    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
#old_people
    old_people = [{**worker, **{"old": worker["age"] > 70}} for worker in DATA]

DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]

def run():
  all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"]
  all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
  adults = list(filter(lambda worker: worker["age"] > 18, DATA))
  adults = list(map(lambda worker: worker["name"], adults))
  old_people = list(map(lambda worker: worker | {"old": worker["age"] > 70}, DATA))
  
  all_python_devs_filter = list(filter(lambda worker : worker ["language"] == "python", DATA))
  all_python_devs_map = list(map(lambda worker : worker["name"], all_python_devs_filter))
  
  all_platzi_workers_filter = list(filter(lambda worker : worker["organization"] == "Platzi", DATA))
  all_platzi_workers_map = list(map(lambda worker : worker["name"], all_platzi_workers_filter))

  adult = [worker["name"] for worker in DATA if worker["age"] > 18]

  for worker in adult:
    print(worker)

if __name__ == '__main__':
  run()

Ac谩 esta mi humilde c贸digo, la verdad no supe como implementar lo ultimo de crear un nuevo diccionario con un nuevo criterio con list comprengetion, pero ac谩 est谩n todos los demas diccionarios con los filters, maps y list comprengetion invertidos.

def run():
## Lista de python devps con filter y map
    all_python_deps = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_deps = list(map(lambda worker: worker["name"], DATA))
    print("Todos los Python deps son:")
    print(all_python_deps)
## Lista de Platzi workers con filter y map
    all_platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers = list(map(lambda worker: worker["name"], DATA))
    print("Todos los Platzi workers son:")
    print(all_platzi_workers)
## Todos los mayores a 18 a帽os con list comprengetion
    all_adults = [worker["name"] for worker in DATA if worker["age"] > 17]
    print("Todos los mayores de 18 son:")
    print (all_adults)

if __name__ == '__main__':
    run()

Reto

    #RETO
     #ver trabajadores que usan lenguaje python usando filter y maps
    all_python_devs_r=list(map(lambda worker: worker["name"] ,filter(lambda worker: worker["language"]=="python",DATA)))   
    #ver trabajadores cuya organizacion es Platzi usando filter y maps
    all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
    all_platzi_workers_r=list(map(lambda worker: worker["name"] ,filter(lambda worker: worker["organization"]=="Platzi",DATA)))
    #Trabajadores mayores de 18 a帽os con list_comprehensions
    adults_r = [worker["name"] for worker in DATA if worker["age"] >= 18]
    #Trabajadors agregandole una nueva llave "old" si es mayor de 70 a帽os
    old_people_r = [worker | {"old": worker["age"] > 70} for worker in DATA ] #solo Python 3.9
    
       
    print("-"*20+" Trabajadores que manejan Python" + "-"*20)
    for worker in all_python_devs_r:
        print(worker)    
    print("-"*20+" Ver Trabajadores de Platzi" + "-"*20)
    for worker in all_platzi_workers_r:
        print(worker)
    print("-"*20+" Ver Trabajadores mayores de 18 a帽os" + "-"*20)
    for worker in adults_r:
        print(worker)
    print("-"*20+" Ver Trabajadores mayores de 70 a帽os" + "-"*20)
    for worker in old_people_r:
        print(worker)

if __name__ == '__main__':
    run()
`    all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
    all_platzi_workers = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_platzi_workers = list(map(lambda worker: worker['name'], all_platzi_workers)) 

    adults = [worker['name'] for worker in DATA if worker['age'] > 18]

    old_people = [worker | {'old': worker['age'] > 70} for worker in DATA]

    for worker in old_people:
        print(worker)e> 

Aqu铆 comparto la forma en la que solucion茅 los retos

DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]

def run():
    #all_python_devs = [worker["name"] for worker in DATA if worker["language"]=="python"]
    all_pythoin_devs = list(filter(lambda worker: worker["language"]=="python", DATA))
    all_pythoin_devs = list(map(lambda worker: worker["name"], all_pythoin_devs))
    #all_Platzi_workers = [worker["name"] for worker in DATA if worker["organization"]=="Platzi"]
    all_Platzi_workers = list(filter(lambda worker: worker["organization"]=="Platzi", DATA))
    all_Platzi_workers = list(map(lambda worker: worker["name"], all_Platzi_workers))
    adults = list(filter(lambda worker: worker["age"]>18, DATA))
    adults = list(map(lambda worker: worker["name"], adults))
    #old_people = list(map(lambda worker: worker | {"old": worker["age"]>70}, DATA))
    old_people = [worker | {"old": True if worker["age"]>70 else False } for worker in DATA ]
    for worker in old_people:
        print(worker)

if __name__=='__main__':
    run()```

Reto Completado
Realic茅 en una s贸la l铆nea los comandos de map y filter, para 鈥渁horrar鈥 tiempo, s贸lo que puede llegar a revolverse un poco. Me di cuenta que la funci贸n de filter permite usar funciones condicionales, mientras que map, literalmente s贸lo mapea una lista y se puede realizar operaciones en sus datos.

  • En primer lugar hice el filter.

  • La lista de resultado es la que recibe map, junto a su operaci贸n de devolver los nombres

  • Los siguientes puntos fueron comprehensions y utilic茅 el pipe para crear un nuevo campo.

# Reto
def main(): 
	# Se tienen que usar dos procesos para regresar s贸lo los nombres que deseamos. 
	# var = list(map(lambda, list(filter(lambda,DATA))))

    all_python_devs= list(map(lambda worker: worker['name'],list(filter(lambda worker: worker['language']=='python',DATA))))
    all_platzi_workers = list(map(lambda worker: worker['name'],list(filter(lambda worker:worker['organization']=='Platzi',DATA))))
    adultos = [worker['name'] for worker in DATA if worker['age']>18]
    old = [worker | {'old': worker['age']>70} for worker in DATA]
    return all_python_devs, all_platzi_workers,adultos, old
main()

organization_platzi = list(filter(lambda workers: workers[鈥榦rganization鈥橾 == 鈥楶latzi鈥, DATA))

organization_platzi = list(map(lambda workers: workers['name'], organization_platzi))

list_age = [worker['name'] for worker in DATA if worker['age'] > 18]

list_old = [worker | {'old': worker['age'] > 70} for worker in DATA]

#usando filter y map:

#all_python_devs = list(filter(lambda worker: worker["language"]=="python", DATA))
#all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

#all_platzi_worker = list(filter(lambda worker: worker["organization"]=="Platzi", DATA))
#all_platzi_worker = list(map(lambda worker: worker["name"], all_platzi_worker))

#usando list comprehensions:

adults = [worker["name"] for worker in DATA if worker["age"] > 18]
old_people = [worker | {"old": worker["age"] > 70} for worker in DATA]
#for worker in all_python_devs:
#for worker in all_platzi_worker:
#for worker in adults:

for worker in old_people:
    print(worker)

Reto 馃

def run():
    #High Order Functions
    all_Python_Devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_Python_Devs = list(map(lambda worker: worker["name"], all_Python_Devs))
    for worker in all_Python_Devs:
        print(worker)

    all_Platzi_Workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_Platzi_Workers = list(map(lambda worker: worker["name"], all_Platzi_Workers))
    for worker in all_Platzi_Workers:
        print(worker)
        
    #List Comprehensions
    old_People = [worker["name"] for worker in DATA if worker["age"] > 70]
    for worker in old_People:
        print(worker)
    
    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    for worker in adults:
        print(adults)
    

if __name__ == '__main__':
    run()
# Comprehensions solutions
    # all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"]
    # all_Platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
    # adults =  [worker["name"] for worker in DATA if worker["age"] > 18]
    # old_people = [worker["name"] for worker in DATA if worker["age"] > 70]

# High order functions
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(filter(lambda worker: worker["name"], all_python_devs))

    all_Platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_Platzi_workers = list(map(lambda worker: worker["name"], all_Platzi_workers))

    adults = list(filter(lambda worker: worker["age"] > 18, DATA))
    adults = list(map(lambda worker: worker["name"], adults))

    old_people = list(map(lambda worker: worker | {"old": worker["age"] > 70}, DATA))

    for worker in old_people:
        if worker["old"] == True:
            print(worker["name"])
#challenge

    _all_python_devs=list(filter(lambda worker: worker["language"]=="python", DATA))

    print("##### _all_python_devs #####")
    for worker in _all_python_devs:
        print(worker["name"])

    _all_platzi_workers = list(filter(lambda worker: worker["age"]>18, DATA))
    print("##### _all_platzi_workers #####")
    for worker in _all_platzi_workers:
        print(worker["name"])

    _adults = [worker["name"] for worker in DATA if worker["age"]>18]
    print("##### _adults #####")
    for worker in _adults:
        print(worker)

from Data_filtrer import DATA

def run():
# all_python_devs= [ worker [鈥榥ame鈥橾 for worker in DATA if worker [鈥榣anguage鈥橾 == 鈥榩ython鈥 ]
all_python_devs = list(filter(lambda worker: worker [鈥榣anguage鈥橾 == 鈥榩ython鈥, DATA ))

# all_platzi_workers = [worker ['name'] for worker in DATA if worker ['organization'] == 'Platzi' ]
all_platzi_workers = list(map(lambda worker: worker ['organization'] == 'Platzi', DATA  ))

# adults = list(filter(lambda worker: worker['age'] > 18 , DATA))
adults = [worker for worker in DATA if worker['age'] > 18]

# adults=list(map(lambda worker: worker ['name'], adults))
adults = [worker['name'] for worker in adults ]

# old_people = list(map(lambda worker: worker | {'old': worker['age'] > 70}, DATA ))
old_people = [worker for worker in DATA if worker['age'] > 70 ]
# old_people = list(map(lambda worker: {**worker, **{"old": worker["age"] > 70}}, DATA))




# for worker in all_python_devs:
#     print(worker)

# for worker in all_platzi_workers:
#     print(worker)

# for worker in adults:
#     print( worker)

# for worker in old_people:
#     print(worker)

for worker in all_python_devs, all_platzi_workers, adults, old_people:
    print(worker)

if name == 鈥main鈥:
run()

<code> 
 ## ------------------challlenge------------------------------------------------------------

    #challenge with high order functions---------------

    print()
    print("-------------CHALLENGE------------")

    all_python_devs_2 = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs_2 = list(map(lambda worker: worker["name"], all_python_devs_2))
    for worker in all_python_devs_2:
        print(worker)

    print()

    all_platzi_workers__2 = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers__2 = list(map(lambda worker: worker["name"], all_platzi_workers__2))
    for worker in all_platzi_workers__2:
        print(worker)

    #callege with list comprenhesion------------------
    adults_2 = [worker["name"] for worker in DATA  if worker["age"] > 18]
    for worker in adults_2:
        print(worker)
    
    print()

    old_people_2 = [worker | {"old": worker["age"]> 70 }for worker in DATA ]
    for worker in old_people_2:
        print(worker)

Muchachos aqui comparto el codigo de como resolvi el reto

<##Reto Filtrado de trabajadores usando FILTER Y MAP

    ##                       Mapeo de los nombres            
    all_python_devs2 = list(map(lambda worker:worker["name"], 
    #                       Filtrado de los trabajadores que usan python
                            filter(lambda worker:worker["language"] == "python",DATA)))
    

    ##Reto de los trabajadores de platzi usando filter
    all_Platzi_workers2 = list(map(lambda worker:worker["name"], 
    #                          Filtrado de los trabajadores que usan python
                               filter(lambda worker:worker["organization"] == "Platzi",DATA)))
    
    ## LIST COMPREHENSION
    # Reto filtrado de los trabajadores mayores de edad 
    adults2 = [worker["name"] for worker in DATA if worker["age"] > 18]
    
    
    # Reto evaluacion si cada trabajador es mayor de 70. Si lo es agregar el tag old de tipo BOOL
    old_people = [worker | {"old": worker["age"] > 70} for worker in DATA ]
    print(old_people)> 
#Lista de empleados con high order functions
    all_python_devs_r =list(filter(lambda worker: worker["language"]=="python",DATA))

    all_python_devs_r =list(map(lambda worker:worker["name"],all_python_devs_r))

    all_platzi_workers_r=list(filter(lambda worker:worker["organization"]=="Platzi",DATA))

    all_platzi_workers_r=list(map(lambda worker:worker["name"],all_platzi_workers_r))

    #lista de empleados usando list comprehensions
    adults_r =[worker["name"] for worker in DATA if worker["age"]>18]

    old_people_r =[worker | {"old":worker["age"]>70} for worker in DATA ]

    old_people_r_name =[worker["name"] for worker in old_people_r if worker["old"]==True]
def run():
    # filtramos el nombre de todos aquellos que dominen python. filtro con filter por lenguaje, y luego mapeo cada elemento para solamente muestre el nombre de cada trabajador
    all_python_devs = list(filter( lambda worker: worker['language'] == 'python' , DATA))
    all_python_devs = list(map(lambda worker: worker['name'] , all_python_devs))
    print(all_python_devs)

    #idem con todos los trabajadores de platiz:
    all_platzi_workers = list(filter( lambda worker: worker['organization'] == 'Platzi' , DATA))
    all_platzi_workers = list(map(lambda worker: worker['name'] , all_platzi_workers))
    print(all_platzi_workers)
    
    #idem para los trabajadores mayores de 18 a帽os:
    adults = list( filter( lambda worker: worker['age'] >= 18 , DATA))
    adults = list( map(lambda worker: worker['name'] , adults) ) 
    print(adults)

    old_people = [worker['name'] for worker in DATA if worker['age'] > 70 ]
    print(old_people)

    adults = [worker['name'] for worker in DATA if worker['age'] >= 18 ]

Reto:

    # Obtenemos el nombre de todos los que saben python:    
    # Usando list comprehension:
    nombres =[n['name'] for n in DATA if n['language']=='python']
    # Usando filter y map:
    nombres2 = list(filter(lambda n: n['language']=='python' ,DATA)) 
    nombres2 = list(map(lambda x:x['name'], nombres2))

    # Obtenemos el nombre de todos los que trabajan en Platzi
    # Usando list comprehension
    all_platzi = [n['name'] for n in DATA if n['organization'] == 'Platzi']
    # Usando filter y map
    all_platzi2 = list(filter(lambda n: n['organization']=='Platzi' ,DATA)) 
    all_platzi2 = list(map(lambda x:x['name'], all_platzi2))
   
    # Filtramos a los trabajadores mayores de 18 a帽os
    adults = list(filter(lambda x: x['age'] > 18, DATA))
    # Con map creamos una nueva lista que solo contiene el nombre y la edad 
    adults = list(map(lambda x: [x['name'], x['age']], adults))
    # Usando list comprehension
    adults2 = [[n['name'], n['age']] for n in DATA if n['age'] > 18]

    # Anexamos el campo old a DATA
    # Usando map
    old = list(map(lambda x:{**x,**{'old':x['age'] > 70}}, DATA))
    # Usando list comprehension
    old2 = [{**x,**{'old':x['age']>70}} for x in DATA]

Mi humilde aporte

from data_worker import DATA

def challenge():
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

    all_Platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi",DATA))
    all_Platzi_workers = list(map(lambda worker: worker["name"], all_Platzi_workers))

    adults = [worker["name"] for worker in DATA if worker["age"] > 18]

    old_people = [worker | {"old": worker["age"] > 70} for worker in DATA]


    # for worker in all_python_devs:
    #     print(worker)

    # for worker in all_Platzi_workers:
    #     print(worker)

    # for worker in adults:
    #     print(worker)

    for worker in old_people:
        print(worker)


if __name__ == '__main__':
    challenge() 

Mi proyecto realizado agregando algo de formato

DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]

def run():
    #*************************************************************************************************
    #Vamos a filtrar todos los trabajadores que saben de python.Lo hacemos con una list comprehension
    print("-----------------------------------------")
    print("TRABAJADORES QUE SABEN PYTHON")
    print("Utilizando List Comprehension")
    all_python_devs = [worker["name"] for worker in DATA if worker["language"] == "python"]
    print(all_python_devs)#Con este print tendremos en pantalla los resultados pero en forma de lista
    #Con este "for" veremos en pantalla los resultados sin tener forma de lista
    for worker in all_python_devs:
        print(worker)
    print("\n")

    #Ahora lo mismo pero con HOF (High Order Function)
    print("Utilizando HOF")
    all_python_devs_hof = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs_hof = list(map(lambda worker: worker["name"], all_python_devs_hof))
    for worker in all_python_devs_hof:
        print(worker)
    print("---------------------------------------\n")
    #**************************************************************************************************
    #Vamos a filtrar todos los trabajadores que trabajan en Platzi.Lo hacemos con una list comprehension
    print("TRABAJADORES QUE TRABAJAN EN PLATZI")
    print("Utilizando List Comprehension")
    all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"] == "Platzi"]
    print(all_platzi_workers)#Con este print tendremos en pantalla los resultados pero en forma de lista
    #Con este for veremos en pantalla los resultados sin tener forma de lista
    for worker in all_platzi_workers:
        print(worker)
    print("\n")

    #Ahora lo mismo pero con HOF (High Order Function)
    print("Utilizando HOF")
    all_platzi_workers_hof= list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers_hof = list(map(lambda worker: worker["name"], all_platzi_workers_hof))
    for worker in all_platzi_workers_hof:
        print(worker)
    print("---------------------------------------\n")
    #***************************************************************************************************
    #Ahora queremos saber cuantos devs son adultos (>18), pero lo haremos con la HOF "Filter" and "Map"
    print("TRABAJADORES ADULTOS")
    print("Utilizando HOF")
    adults = list(filter(lambda worker: worker["age"] > 18, DATA))
    adults = list(map(lambda worker: worker["name"], adults))
    
    for worker in adults:
        print(worker)
    print("\n")

    #Ahora haremos lo mismo pero con list_comprehension
    print("Utilizando List Comprehension")
    adults = [worker["name"] for worker in DATA if worker["age"] > 18]
    print(adults)#Con este print tendremos en pantalla los resultados pero en forma de lista
    #Con este "for" veremos en pantalla los resultados sin tener forma de lista
    for worker in adults:
        print(worker)
    print("---------------------------------------\n")
    #*****************************************************************************************************
    #Ahora crearemos un item en los diccionarios donde evalue si la persona
    #tiene mas de 50 anos de edad. Esto lo haremos con la HOF "Map",pero debemos tener minimo python 3.9 para que el comando "pipe" funcione
    print("ASIGNAMOS UN NUEVO ITEM A LOS DICCIONARIOS DONDE SI TIENE MAS DE 50 ANOS NOS DICE SI ES TRUE O FALSE")
    print("Utilizando HOF")
    old_people = list(map(lambda worker: worker | {"old": worker["age"] > 50}, DATA))
    for worker in old_people:
        print(worker)
    print("\n")

if __name__== '__main__':
    run()

Profesor y compa帽eros buenas tardes, a continuaci贸n como son mis funciones del reto:

# reto

    name_python2 = list(filter(lambda worker: worker["language"] == "python", DATA))
    name_python2 = list(map(lambda worker : worker["name"],name_python2))

    name_platzi2 = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    name_platzi2 = list(map(lambda worker : worker["name"], name_platzi2))

    adult2 = [worker["name"] for worker in DATA if worker["age"] > 18]

    old_people2  = [worker | { "old" : worker["age"] > 70} for worker in DATA]

Mi aporte, considero que esta bien simplificado c;

    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

    adults = [worker["name"] for worker in DATA if worker["age"] > 18]

    old_people = [worker | {"old" : worker["age"] > 70} for worker in DATA]

Mi Reto =)

#Reto
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker : worker["name"],all_python_devs))
    print(all_python_devs)

    all_platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers = list(map(lambda worker: worker["name"], all_platzi_workers))
    print(all_platzi_workers)

    adults = [worker["name"] for worker in DATA if worker["age"] >= 18]
    print(adults)

    old_people = [worker | {"old" : worker["age"] > 70} for worker in DATA]
    for worker in old_people:
        print(worker)

Filtrando Datos con listas comprimidas

DATA = [
{
鈥榥ombre鈥: 鈥楩acundo鈥,
鈥榚dad鈥: 72,
鈥榦rganizacion鈥: 鈥楶latzi鈥,
鈥榗argo鈥: 鈥楾echnical Coach鈥,
鈥榣enguaje鈥: 鈥榩ython鈥,
},
{
鈥榥ombre鈥: 鈥楲uisana鈥,
鈥榚dad鈥: 33,
鈥榦rganizacion鈥: 鈥楪lobant鈥,
鈥榗argo鈥: 鈥楿X Designer鈥,
鈥榣enguaje鈥: 鈥榡avascript鈥,
},
{
鈥榥ombre鈥: 鈥楬茅ctor鈥,
鈥榚dad鈥: 19,
鈥榦rganizacion鈥: 鈥楶latzi鈥,
鈥榗argo鈥: 鈥楢ssociate鈥,
鈥榣enguaje鈥: 鈥榬uby鈥,
},
{
鈥榥ombre鈥: 鈥楪abriel鈥,
鈥榚dad鈥: 20,
鈥榦rganizacion鈥: 鈥楶latzi鈥,
鈥榗argo鈥: 鈥楢ssociate鈥,
鈥榣enguaje鈥: 鈥榡avascript鈥,
},
{
鈥榥ombre鈥: 鈥業sabella鈥,
鈥榚dad鈥: 30,
鈥榦rganizacion鈥: 鈥楶latzi鈥,
鈥榗argo鈥: 鈥楺A Manager鈥,
鈥榣enguaje鈥: 鈥榡ava鈥,
},
{
鈥榥ombre鈥: 鈥楰aro鈥,
鈥榚dad鈥: 23,
鈥榦rganizacion鈥: 鈥楨veris鈥,
鈥榗argo鈥: 鈥楤ackend Developer鈥,
鈥榣enguaje鈥: 鈥榩ython鈥,
},
{
鈥榥ombre鈥: 鈥楢riel鈥,
鈥榚dad鈥: 32,
鈥榦rganizacion鈥: 鈥楻appi鈥,
鈥榗argo鈥: 鈥楽upport鈥,
鈥榣enguaje鈥: 鈥樷,
},
{
鈥榥ombre鈥: 鈥楯uan鈥,
鈥榚dad鈥: 17,
鈥榦rganizacion鈥: 鈥樷,
鈥榗argo鈥: 鈥楽tudent鈥,
鈥榣enguaje鈥: 鈥榞o鈥,
},
{
鈥榥ombre鈥: 鈥楶ablo鈥,
鈥榚dad鈥: 32,
鈥榦rganizacion鈥: 鈥楳aster鈥,
鈥榗argo鈥: 鈥楬uman Resources Manager鈥,
鈥榣enguaje鈥: 鈥榩ython鈥,
},
{
鈥榥ombre鈥: 鈥楲orena鈥,
鈥榚dad鈥: 56,
鈥榦rganizacion鈥: 鈥楶ython Organization鈥,
鈥榗argo鈥: 鈥楲anguage Maker鈥,
鈥榣enguaje鈥: 鈥榩ython鈥,
},
{
鈥榥ombre鈥: 鈥楢bel鈥,
鈥榚dad鈥: 61,
鈥榦rganizacion鈥: 鈥楥asero鈥,
鈥榗argo鈥: 鈥楢prendiz de Python鈥,
鈥榣enguaje鈥: 鈥榩ython鈥,
},
] # ;-D

def run():

# Lista de nombres de quienes trabajan con Python, usando primero el m茅todo
# 'list comprehesions' y luego los m茅todos 'filter' y 'map'
print("Lista de nombres relacionados con lenguaje Python usando 'list comprehesions':")
desarrolladores_python = [trabajador['nombre'] for trabajador in DATA if trabajador['lenguaje'] == 'python']
for personal in desarrolladores_python:
    print(personal)

print("\nCon 'filter' y 'map':")
desarrolla_python = list(filter(lambda trabajador: trabajador['lenguaje'] == 'python', DATA))
desarrolla_python = list(map(lambda trabajador: trabajador['nombre'], desarrolla_python))
for personal in desarrolla_python:
    print(personal)

# Lista de nombres de quienes trabajan en Platzi, usando primero el m茅todo
# 'list comprehesions' y luego los m茅todos 'filter' y 'map'
print("\nLista de nombres relacionados con organizaci贸n usando 'list comprehesions':")
trabajadores_platzi =  [trabajador['nombre'] for trabajador in DATA if trabajador['organizacion'] == 'Platzi']
for personal in trabajadores_platzi:
    print(personal)

print("\nCon 'filter' y 'map':")
trabaja_platzi = list(filter(lambda trabajador: trabajador['organizacion'] == 'Platzi', DATA))
trabaja_platzi = list(map(lambda trabajador: trabajador['nombre'], trabaja_platzi))
for personal in trabaja_platzi:
    print(personal)

# Lista de nombres de quienes son adultos, usando primero el m茅todo
#  los m茅todos 'filter' y 'map' y luego 'list comprehesions'
print("\nLista de nombres de adultos usando 'filter' y 'map':")
adultos = list(filter(lambda trabajador: trabajador["edad"] > 18, DATA))
adultos = list(map(lambda trabajador: trabajador['nombre'], adultos))
for personal in adultos:
    print(personal)

print("\nCon 'list comprehesions':")
adultos =  [trabajador['nombre'] for trabajador in DATA if trabajador['edad'] > 18]
for personal in adultos:
    print(personal)

# Lista de nombres de quienes son mayores de edad, usando el m茅todo
# de 'list comprehesions'
print("\nLista de dccionarios con clave a帽adida de mayores de edad usando el 'list comprehesions':")
gente_mayor =  [trabajador['nombre'] for trabajador in DATA if trabajador['edad'] > 60]
for personal in gente_mayor:
    print(personal)

if name == 鈥main鈥:
run()

#Solucion al Reto.

<code> 
def run():
    i = 0

    print("""Colaboradores que dominan Python: 
    """)
    all_python_devs = list(filter(lambda worker: worker['language'] == 'python', DATA))
    all_python_devs = list(map(lambda worker: worker['name'], all_python_devs))
    for worker in all_python_devs:
        i = i+1
        print(i, '-', worker)
    i = 0

    print("""Colaboradores que trabajan en Platzi: 
    """)
    all_Platzi_workes = list(filter(lambda worker: worker['organization'] == 'Platzi', DATA))
    all_Platzi_workes = list(map(lambda worker: worker['name'], all_Platzi_workes))
    for worker in all_Platzi_workes:
        i = i+1
        print(i, '-', worker)
    i = 0

    print("""Colaboradores que mayores de edad: 
    """)
    old_people = [x['name'] for x in DATA if x['age'] > 18]
    for worker in old_people:
        i = i+1
        print(i, '-', worker)
    i = 0

    print("""Colaboradores que mayores de 70 anios: 
    """)
    adults_people = [x['name'] for x in DATA if x['age'] > 70]
    for worker in adults_people:
        i = i+1
        print(i, '-', worker)
    i = 0


if __name__ == "__main__":
    run()

Como no se como actualizarme a python 3.9, y solo usando python 3.8 lo resolvi asi 馃槙

#El ejemplo del profee
adults = list(filter(lambda worker: worker["age"] > 18, DATA))
adults = list(map(lambda worker: worker["name"], adults))

Lo resumi asi, pero creo que es menos entendible, o talvez no鈥

all_python_devs = list(map(lambda worker: worker["name"], list(
		filter(lambda worker: worker["language"] == "python", DATA))))
all_Platzi_workers = list(map(lambda worker: worker["name"], list(
		filter(lambda worker: worker["organization"] == "Platzi", DATA))))

Mi soluci贸n al reto:


    #GET All python devs - high functions
    all_python_devs_func = list(filter(lambda worker: worker["language"] == "python",DATA))
    all_python_devs_func = list(map(lambda worker: worker["name"],all_python_devs_func))
    #GET All workers from platzi  - high functions
    all_platzi_workers_func = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers_func = list(map(lambda worker: worker["name"], all_platzi_workers_func))
    #GET old_people - list comprehensions
    old_people_comp = [worker | {"old": True} for worker in DATA if worker["age"] > 70]
    #GET adults - list comprenhension
    adults = [worker["name"] for worker in DATA if worker["age"] > 18]

Mi codigo

RETO:

   #obteniendo desarrolladores de python de Platzi con Hugh order functions
    all_python_devs = list(filter(lambda worker: worker["language"] == "python", DATA))
    all_python_devs = list(map(lambda worker: worker["name"], all_python_devs))

   #obteniendo trabajadores de Platzi con Hugh Order Functions
    all_platzi_workers = list(filter(lambda worker: worker["organization"] == "Platzi", DATA))
    all_platzi_workers = list(map(lambda worker: worker["name"], all_platzi_workers))


    #obteniendo adultos con List Comprehensions
    adults = [worker["name"] for worker in DATA if worker["age"] >= 18]

    #agregando nuevo valor "old" para cada uno de los datos con list comprehensions
    old_people = [worker | {"old": worker["age"] > 70} for worker in DATA]

Listo 馃槃

Reto cumplido, aqu铆 el c贸digo:

DATA = [
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H茅ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]

def run():
    print("-----------------------------------------------------------------------------------")
    # Usando comprehensions:
    all_workers_py = [worker['name'] for worker in DATA if worker['language']=='python']
    print(all_workers_py)
    #Usando Funciones an贸nimas(lambda) y funciones de order superior(filter y map):
    all_workers_py_02 = list(filter(lambda worker: worker['language']=='python', DATA))
    all_workers_py_02 = list(map(lambda worker: worker['name'], all_workers_py_02))
    print(all_workers_py_02)
    
    print("-----------------------------------------------------------------------------------")

    # Usando comprehensions:
    all_workers_platzi = [worker['name'] for worker in DATA if worker['organization']=='Platzi']
    print(all_workers_platzi)
    #Usando Funciones an贸nimas(lambda) y funciones de order superior(filter y map):
    all_workers_platzi_02 = list(filter(lambda worker: worker['organization']=='Platzi', DATA))
    all_workers_platzi_02 = list(map(lambda worker: worker['name'], all_workers_platzi_02))
    print(all_workers_platzi_02)
    
    print("-----------------------------------------------------------------------------------")
    
    # Usando comprehensions:
    all_age_18 = [worker['name'] for worker in DATA if worker['age']>=18]
    print(all_age_18)
    #Usando Funciones an贸nimas(lambda) y funciones de order superior(filter y map):
    adults = list(filter(lambda worker: worker['age']>=18, DATA))
    adults = list(map(lambda worker: worker['name'], adults))
    print(adults)

    print("-----------------------------------------------------------------------------------")
    # Usando comprehensions:
    old_people = [worker | {'old': worker['age']>70} for worker in DATA]
    print(old_people)
    #Usando Funciones an贸nimas(lambda) y funciones de order superior(filter y map):
    old_people_02 = list(map(lambda worker: worker | {'old': worker['age']>70}, DATA))
    print(old_people_02)

if __name__ == '__main__':
    run()
DATA = [ # que en el futuro de debe modificarse por lo que se deberia llamar constante mas no variable y todo por estar en mayuscula
    {
        'name': 'Facundo',
        'age': 72,
        'organization': 'Platzi',
        'position': 'Technical Coach',
        'language': 'python',
    },
    {
        'name': 'Luisana',
        'age': 33,
        'organization': 'Globant',
        'position': 'UX Designer',
        'language': 'javascript',
    },
    {
        'name': 'H脙漏ctor',
        'age': 19,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'ruby',
    },
    {
        'name': 'Gabriel',
        'age': 20,
        'organization': 'Platzi',
        'position': 'Associate',
        'language': 'javascript',
    },
    {
        'name': 'Isabella',
        'age': 30,
        'organization': 'Platzi',
        'position': 'QA Manager',
        'language': 'java',
    },
    {
        'name': 'Karo',
        'age': 23,
        'organization': 'Everis',
        'position': 'Backend Developer',
        'language': 'python',
    },
    {
        'name': 'Ariel',
        'age': 32,
        'organization': 'Rappi',
        'position': 'Support',
        'language': '',
    },
    {
        'name': 'Juan',
        'age': 17,
        'organization': '',
        'position': 'Student',
        'language': 'go',
    },
    {
        'name': 'Pablo',
        'age': 32,
        'organization': 'Master',
        'position': 'Human Resources Manager',
        'language': 'python',
    },
    {
        'name': 'Lorena',
        'age': 56,
        'organization': 'Python Organization',
        'position': 'Language Maker',
        'language': 'python',
    },
]



#Osea de cada conjunto(dediccionario) que va estar representado por x .
#Entendimiento; para poder iterar con un bucle mi diccionario ser脙隆 necesario colocarla dentro de una lista.
def run():
    
# =============================================================================
# Primer m茅todo(List-comprehension-Higher order functions)   
# =============================================================================
    all_python_devs = [worker["name"] for worker in DATA if worker["language"]=="python"]
    print("Desarrolladores de platzi:")
    print(all_python_devs)
    all_platzi_workers = [worker["name"] for worker in DATA if worker["organization"]=="Platzi"]
    print("Desarrolladores de platzi:")
    print(all_platzi_workers)
    print("\n"*2)
    #Usamos las funciones de orden superio con filter y map:
    adults = list(filter(lambda worker: worker["age"]>18 , DATA))#Supuestamente donde se va a iterar en DATA y quien va a ser cada unos de los valores worker(par谩metro de la funcion an贸nima labmda) y lo que va a ser almacenados ser谩 justamanete mi worker la cual esta representando a cada unos de mis diccionarios 
    adults = list(map(lambda worker: worker["name"], adults))# Para map el la seccion de condicion significa que justo en esa parte que solo se almancenar谩.
    # !!! Para el caso de map lo que va a almacenar sencillamente es lo que va en la seccion de condicion.
    print("Trabajadores mayores de edad:")
    print(adults)
    print("\n")
    old_people = list(map(lambda worker : worker | {"old": worker["age"]>70}, DATA))
    print(old_people)# Para esta interesante funcion lo que va a suceder es que primero se va a almacenar cada uno de los diccionarios y ademas que se a帽adir谩 una nueva clave a cada uno de los diccionarios y teninedo como valor  True or False si se cumple tal condicion
    
    for new in old_people:
        print(new)
        
# =============================================================================
# Segundo m茅todo(Higher order functions- list-comprehension)   
# =============================================================================
    print("\n"*2, "---------------------------------------------------------")    
    alpydevs = list(filter(lambda worker: worker["language"]=="python", DATA)) #Con filter filtro en conjunto
    alpydevs = list(map(lambda worker : worker["name"], alpydevs))      #   y con map almaceno datos en especifico ya no con conjuntos
    print("Desarrolladores en python:")#Una vez que eh filtrado tengo que extraer los nombres
    print(alpydevs)
    
    alplatworkers = list(filter(lambda worker : worker["organization"]=="Platzi", DATA))
    alplatworkers = list(map(lambda worker : worker["name"], alplatworkers))
    print("Desarrolladores de platzi:")
    print(alplatworkers)
    
    print("\n")
    adults = [worker["name"] for worker in DATA if worker["age"]>18]
    print("Trabajadores mayores de edad:")
    print(adults)
    print("\n")
    old_people = [worker | {"old": worker["age"] > 70 } for worker in DATA]
    #Esta es la forma de como quiero guardarlos cada uno 
    for ol in old_people:
        print(ol)
        
    
        

if __name__=="__main__":
    run()
    

Eso que se hizo de python 3.9 estuvo bueno!