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
Tom Ron
  • 5,906
  • 3
  • 22
  • 38
Alexander Golys
  • 683
  • 8
  • 23

0 Answers0