请用高阶函数map求1 2 3 4 5 6中每个元素的平方python
可以这样写:
lst = [1, 2, 3, 4, 5, 6]
squares = list(map(lambda x: x**2, lst))
print(squares)
输出结果为:
[1, 4, 9, 16, 25, 36]
原文地址: https://www.cveoy.top/t/topic/ci3H 著作权归作者所有。请勿转载和采集!
安全问答是一个知识全球问答,包含丰富的问答知识
可以这样写:
lst = [1, 2, 3, 4, 5, 6]
squares = list(map(lambda x: x**2, lst))
print(squares)
输出结果为:
[1, 4, 9, 16, 25, 36]
原文地址: https://www.cveoy.top/t/topic/ci3H 著作权归作者所有。请勿转载和采集!