I encountered a problem online where I had to write a function that takes a list of numbers and I have to return its additive inverse. This was one of the answers but I don't understand how does that exactly work?:
def invert(lst):
return [-x for x in lst]
def invert(lst):
return [-x for x in lst]
=
def invert(lst):
return_list = []
for x in lst:
return_list.append(-x)
return return_list