def replace_insensitive(string, target, replacement):
 no_case = string.lower()
 index = no_case.rfind(target.lower())
 if (index >= 0):
  return ((string[:index] + replacement) + string[(index + len(target)):])
 else:
  return string

def replace_insensitive ( string , target , replacement ) : no_case = string . lower ( ) index = no_case . rfind ( target . lower ( ) ) if ( index >= 0 ) : return ( ( string [ : index ] + replacement ) + string [ ( index + len ( target ) ) : ] ) else : return string
similar to string .