Your question is Add and Print Array Output. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
ABC Family needs a small utility to calculate totals from an array of integer values. Given an array, traverse it once, add every element, and return the final sum so the caller can print it.
Implement sum_array(nums), where nums is a list of integers. Return a single integer equal to the sum of all values in nums. The function should not modify the input array. For an empty array, return 0.
The caller may print the returned value as needed. Do not use Python's built-in sum() function, so the implementation demonstrates basic array traversal and accumulation.
def sum_array(nums):