def find_position(string, index, last_index, last_pos):
 lines = string.count('\n', last_index, index)
 if (lines > 0):
  column = (index - string.rfind('\n', last_index, index))
 else:
  column = (last_pos[1] + (index - last_index))
 return ((last_pos[0] + lines), column)

def find_position ( string , index , last_index , last_pos ) : lines = string . count ( '\n' , last_index , index ) if ( lines > 0 ) : column = ( index - string . rfind ( '\n' , last_index , index ) ) else : column = ( last_pos [ 1 ] + ( index - last_index ) ) return ( ( last_pos [ 0 ] + lines ) , column )
given a string and index .