x = [1, 2, 3]
y = list(map(lambda x: 2 * x * 2, x))
print(y)
z = list(map(lambda i: i, str(1234)))
print(z)
def my_map(fn,x):
y = []
for i in x:
y.append(fn(i))
return y
结果
[4, 8, 12]
['1', '2', '3', '4']
x = [1, 2, 3]
y = list(map(lambda x: 2 * x * 2, x))
print(y)
z = list(map(lambda i: i, str(1234)))
print(z)
def my_map(fn,x):
y = []
for i in x:
y.append(fn(i))
return y
结果
[4, 8, 12]
['1', '2', '3', '4']