這樣寫更方便吧?
def square_of_sum(L):
? ? newL = map(lambda x:x*x,L)
? ? return sum(newL)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
def square_of_sum(L):
? ? newL = map(lambda x:x*x,L)
? ? return sum(newL)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2019-08-28
舉報
2019-08-28
lambda是一個匿名函數