Sobes.tech
Junior — Middle+

Transform negative elements of the function result without changing its code

livecode

Task condition

It is necessary to change the way the foo function is used so that all numbers it returns with a '‑' sign become positive. The foo function itself must not be modified.


def foo(length: int = 10) -> list[int]:
    is_minus = length < 0
    return [i if not is_minus else -i for i in range(abs(length)) if i % 2 == 0]

Your solution should wrap the call to foo and adjust the resulting list without changing the implementation of the function.