The Anonymous batch validator receives an ordered list of integer values. Valid values are non-negative and should be added to the running total. A negative value marks the first invalid record, so processing must stop immediately.
Implement sum_until_negative(nums) using a loop, an if-else condition, and break. Return the sum of all consecutive non-negative values before the first negative value. Values after the first negative value must not affect the result.
nums, a list of integers.0.def sum_until_negative(nums):