Substr() normally (i.e. PHP, and Perl) works this way:
s = Substr(s, beginning, LENGTH)
So the parameters are beginningbeginning and LENGTHLENGTH.
But Python's behaviour is different,different; it expects beginning and one after END (!). This is difficult to spot by beginners. So the correct replacement for Substr(s, beginning, LENGTH) is
s = s[ beginning : beginning + LENGTH]