0 out of 464 challenges solved

Sum of Digits in List

Write a Python function `sum_of_digits(nums)` that takes a list of integers as input and returns the sum of the digits of all the numbers in the list. The function should handle both positive and negative numbers, and ignore any non-numeric elements in the list.

#### Example Usage
```python [main.nopy]
print(sum_of_digits([10, 2, 56]))  # Output: 14
print(sum_of_digits([10, 20, -4, 5, -70]))  # Output: 19
print(sum_of_digits([123, -456, 789]))  # Output: 45
```

#### Constraints
- The input list may contain integers, floats, or non-numeric elements.
- Only the digits of integers should be considered for the sum.
- Negative signs should be ignored when summing the digits.
def sum_of_digits(nums):
    """
    Calculate the sum of digits of all numbers in the given list.

    Args:
        nums (list): A list of integers.

    Returns:
        int: The sum of all digits in the list.
    """
    # Initialize the sum
    total_sum = 0
    # Iterate through the list
    for num in nums:
        # Process each number to extract digits
        pass  # Replace with your implementation
    return total_sum