MST

星途 面试题库

面试题:Python中map函数的应用

假设有一个列表[1, 2, 3, 4, 5],使用map函数将列表中的每个元素都平方,最后返回一个新的列表。请用Python代码实现。
43.4万 热度难度
编程语言Python

知识考点

AI 面试

面试题答案

一键面试
original_list = [1, 2, 3, 4, 5]
result = list(map(lambda x: x**2, original_list))
print(result)