Is there any more pythonic way of calculating value based on interval belonging? I'm looking for more elegant form of this function:
def c(x):
if x < -.3:
return -1
if x < .3:
return 0
return 1
Is there any more pythonic way of calculating value based on interval belonging? I'm looking for more elegant form of this function:
def c(x):
if x < -.3:
return -1
if x < .3:
return 0
return 1