7

what is the python expression for defining a range of numbers?

I have tried numerous combinations but cannot get a simple range of angles (100 -200) to compute correctly.

Screen shot :

Range in Field Calculator needed

1 Answer 1

7
if !ET_Angle! > 100 and !ET_Angle! < 200

To be more complete, put this in the codeblock:

def LeftOrRight(value):
    if value > 100 and value < 200:
         return "LEFT"
    else:
         return "RIGHT"

And in the calculation area, just put:

LeftOrRight(!ET_Angle!)
5
  • 2
    So many people ignore the codeblock. It can be very powerful. Commented Jun 15, 2011 at 18:13
  • I think they ignore it because the term "code" is rather intimidating unless you are familiar with the language. Commented Jun 15, 2011 at 18:23
  • Awesome! That's just what we needed! Much Thanks!! Commented Jun 15, 2011 at 19:53
  • You got it. Sometimes a few examples can make things clearer. Commented Jun 15, 2011 at 20:17
  • i always save these code solutions and i tried using previously saved codeblocks for this today, but needed further schooling on formulating range expressions... not really intimidated by python just exacerbated sometimes due to time constraints and lack of Google-Fu when looking for the answers... GSE is always a great help for filling in the gaps with Google-Fu . Commented Jun 15, 2011 at 21:57

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.