python reduce function to sum array
from functools import reduce
scores = [3, 3, 80, 3, 1]
total = reduce(lambda x, y: x + y, scores)
print(total)
python reduce function to sum array
from functools import reduce
scores = [3, 3, 80, 3, 1]
total = reduce(lambda x, y: x + y, scores)
print(total)
python list sum
To get the sum of a list in python, you just call the built in sum() function.
An example:
>>> lst = [3, 7, 1, 9, 4]
>>> sum(lst)
24
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us