Final answer:
The function get_al1_sum should use a list comprehension and functools.reduce to calculate the sum of absolute values from a list.
Step-by-step explanation:
The function get_al1_sum is intended to return the sum of the absolute values of a list of numbers. To complete the implementation, one needs to use a list comprehension to create a list of the absolute values of the numbers in the given list and then apply the functools module to reduce the new list to a single sum. Here's how you can complete the function:
import functools
def get_al1_sum(lst):
new_lst = [abs(num) for num in lst]
return functools.reduce(lambda a, b: a + b, new_lst)
When you call get_al1_sum([5, -1, 12, -10, 2, 8]), it will return 28, which is the sum of |5| + |-1| + |12| + |-10| + |2| + |8|.