find sum of array in python
Answers
Answered by
8
def calc_sum(arr):
_sum = 0
for n in arr:
_sum += n
return _sum
nums = [int(n) for n in input("enter nums: ").split()]
print(f"sum: {calc_sum(nums)}")
Answered by
0
Explanation:
Input : arr[] = {1, 2, 3}
Output : 6
1 + 2 + 3 = 6
Input : arr[] = {15, 12, 13, 10}
Output : 50
Similar questions