Python list [1,2,3,4,5], using the map () function output [1,4,9,16,25]

l = [1, 2, 3, 4, 5]
def foo(i):
    return i*i

n = map(foo, l)
print(list(n))

Print results 

[1, 4, 9, 16, 25]

 

Guess you like

Origin www.cnblogs.com/loganSxb/p/10980258.html