How would you calculate the sum of an array using Python?
Implement sum_array(nums), which accepts a list of integers and returns their arithmetic sum. The input may be empty, in which case return 0.
Function: def sum_array(nums):
The output must be a single integer.
def sum_array(nums):