-4

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]

1 Answers1

-1
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

Tobias
  • 1
  • 1
    There is 0 need to answer questions like this - perfect duplicates exist. – luk2302 Jul 30 '23 at 20:40
  • Answer needs supporting information Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](https://stackoverflow.com/help/how-to-answer). – moken Aug 01 '23 at 11:54
  • @luk2302 but sometimes people like me really want to help people(yes nice people on stackoverflow they are here) – Tobias Aug 02 '23 at 12:28
  • If you don't have time to enter this,just do comment – Tobias Aug 02 '23 at 12:28