I want to make a lambda corresponding to the signum function in python.
i have tried the following ways
f = lambda x: if x>=0 1 else -1
Then, i want to plot this curve. my code is -
import numpy as np
import matplotlib.pyplot as plt
x=np.arange(-10,10)
y=f(x)
plt.plot(x,y)
plt.show()
By this, I am not getting the desired result. Pls suggest a way in which this can be achieved.