def getFirstWordIndexReverse(firstWord, lines, startIndex):
 for lineIndex in xrange((len(lines) - 1), (startIndex - 1), (-1)):
  if (firstWord == getFirstWord(getSplitLineBeforeBracketSemicolon(lines[lineIndex]))):
   return lineIndex
 return (-1)

def getFirstWordIndexReverse ( firstWord , lines , startIndex ) : for lineIndex in xrange ( ( len ( lines ) - 1 ) , ( startIndex - 1 ) , ( - 1 ) ) : if ( firstWord == getFirstWord ( getSplitLineBeforeBracketSemicolon ( lines [ lineIndex ] ) ) ) : return lineIndex return ( - 1 )
parse gcode in reverse order until the first word if there is one .