← Back to challenges

Additive Inverse

PythonMediumarraysmathhigher_order_functionsloops

Instructions

A number added with its additive inverse equals zero. Create a function that returns a list of additive inverses.

Examples

additive_inverse([5, -7, 8, 3]) ➞ [-5, 7, -8, -3]

additive_inverse([1, 1, 1, 1, 1]) ➞ [-1, -1, -1, -1, -1]

additive_inverse([-5, -25, 35]) ➞ [5, 25, -35]
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Reverse a List