0 out of 464 challenges solved

Element-wise List Subtraction

Write a Python function `sub_list(nums1, nums2)` that takes two lists of numbers, `nums1` and `nums2`, and returns a new list where each element is the result of subtracting the corresponding elements of `nums2` from `nums1`.

#### Example Usage
```python [main.nopy]
sub_list([1, 2, 3], [4, 5, 6])  # Output: [-3, -3, -3]
sub_list([10, 20, 30], [5, 15, 25])  # Output: [5, 5, 5]
sub_list([100, 200], [50, 100])  # Output: [50, 100]
```

#### Constraints
- Both input lists will have the same length.
- The elements of the lists will be integers.
- The function should handle empty lists gracefully.
def sub_list(nums1, nums2):
    """
    Subtracts elements of nums2 from nums1 element-wise.

    Args:
        nums1 (list): The first list of integers.
        nums2 (list): The second list of integers.

    Returns:
        list: A list containing the element-wise subtraction of nums2 from nums1.
    """
    # Implement the function here
    pass