Invert Values

Lists often need the same operation applied to every element. Write a function invert that takes a list lst and returns a new list where each number has the opposite sign. Positive numbers become negative, negative numbers become positive, and an empty list stays empty.

Примеры

Ввод
[1, 2, 3, 4, 5]
Вывод
[-1, -2, -3, -4, -5]
Ввод
[1, -2, 3, -4, 5]
Вывод
[-1, 2, -3, 4, -5]
Ввод
[]
Вывод
[]

Нужно реализовать

def invert(lst: list[int]) -> list[int]:

Теги

listsarray
PostgreSQLv16

Šeit parādīsies koda izpildes rezultāts

Visible tests
1
Input
[1,2,3,4,5]
Expected[-1,-2,-3,-4,-5]
2
Input
[1,-2,3,-4,5]
Expected[-1,2,-3,4,-5]
3
Input
[]
Expected[]
4
Input
[0]
Expected[0]
5
Input
[-1,-1]
Expected[1,1]
6
Input
[1]
Expected[-1]
Focus radio
Paused · SomaFM · Fluid