Python Notes

Replacing List Items

There is a list of integers. Replace negative by -1, positive - by number 1, keep zero unchanged.

The result of an execution of scripts:

[10, -15, 3, 8, 0, 9, -6, 13, -1, 5]
[1, -1, 1, 1, 0, 1, -1, 1, -1, 1]