This commit is contained in:
Angelos Chalaris
2019-09-22 15:36:06 +03:00
committed by GitHub
parent 159cc26814
commit 9b6cec690f

View File

@ -5,11 +5,11 @@ tags: math,list,function,beginner
Returns the sum of a list, after mapping each element to a value using the provided function.
Use `map()` with `fn` to map each element to a value using the provided function, convert to a `list` and use `sum()` to return the sum of the values.
Use `map()` with `fn` to map each element to a value using the provided function, use `sum()` to return the sum of the values.
```py
def sum_by(lst, fn):
return sum(list(map(fn,lst)))
return sum(map(fn,lst))
```
```py