cart_total(prices) that computes the sum of a list of prices using functools.reduce and a lambda — no sum() allowed. An empty cart must return 0 (use the initializer argument).cart_total([99, 1, 250])
350
reduce folds the list pairwise: ((99+1)+250).
reduce(f, seq, initial).
lambda acc, x: acc + x.