0 out of 464 challenges solved

Sum of Array

Write a Python function `sum_of_array(arr)` that takes a list of numbers as input and returns the sum of all the elements in the list.

#### Example Usage
```python [main.nopy]
print(sum_of_array([1, 2, 3]))  # Output: 6
print(sum_of_array([15, 12, 13, 10]))  # Output: 50
print(sum_of_array([0, 1, 2]))  # Output: 3
```

#### Constraints
- The input list will only contain numeric values.
- The list can be empty, in which case the function should return `0`.
def sum_of_array(arr):
    """
    Calculate the sum of all elements in the input list.

    Args:
        arr (list): A list of numeric values.

    Returns:
        int: The sum of the elements in the list.
    """
    # Initialize the sum variable
    total = 0
    # Iterate through the list and add each element to the total
    # Placeholder for the solution
    return total