i'm new in python, i'm learning about lambda and map, but when i was trying some things, i found that one loop was not executing, and i want to know why.
I know it's kind useless to do that, but when i iterate the same list two times, the second time is not executed.
salarios = map(lambda emp: emp.salario, empleados)
print("------SALARIO-------")
for salario in salarios:
print(salario)
print("-----SALARIO2--------")
for salario in salarios:
print(salario)
I get
------SALARIO------- 6700 7500 2100 2150 1800 -----SALARIO2--------
i expect get
------SALARIO------- 6700 7500 2100 2150 1800 -----SALARIO2-------- 6700 7500 2100 2150 1800
why is it happend? it's some lenguaje optimization?