python_map()函式

坐忘游發表於2024-06-13

python_map()函式

def square(x):
    return x * x

numbers = [1, 2, 3, 4, 5]
squared_numbers = map(square, numbers)

for number in squared_numbers:
    print(number)

相關文章