Is there any way in Python to give the opposite of each numeral element of a list in one line, without doing, for example:
list_ = list(range(10))
for x in range(len(list_)):
list_[x] = -list_[x]
In this case, considering the list
[0, 1, 2, 3..., 9]
the output should be
[0, -1, -2, -3..., -9]
Every number of the list should be its opposite.
I tried -list_
but it didn't work.
I searched but I found only how to reverse a list, and not how to oppose its elements (I hope this is the correct word, meaning that each number should end up being its additive inverse.)
I know about list comprehensions, but I was wondering if there was a special keyword in Python to achieve this.