Trying to calculate using Python in 10.3 the "Region" field with text based on the first two characters in a string field called "API_10". Basically, if the left two characters in "API_10" equal "33", then populate "Region" with "North".
API_10[0:2] or API_10[:2]
Also, just pass the whole column to your function since the function does slicing and checking: Region = TextValue(!API_10!)
Joshua is correct... python slicing is 0 based and exclusive of the slice number, hence
whatever[:2] or whatever[0:2] will return 0 and 1. The slice is [start:stop:step]
whatever = 'abcdefg'whatever[0:6:2]'ace'whatever[:6:2]'ace'
or skipping the start and stop
When you do a slice or substring in Python and it starts with "0" then the second number is always the length. This confused me for a while ..... https://www.dotnetperls.com/substring-python
Or the most succinct descriptor... the python docs
Retrieving data ...