Como faço para juntar estas duas funções em uma só? Posso fazer isso? Acredito que o código ficaria muito mais limpo. As funções são as seguintes:
def substituir_codigo(textos, regex):
  if type(textos) == str:
    return regex.sub('CODE',textos)
  else:
    return [regex.sub('CODE', texto) for texto in textos]e essa aqui:
def remover(textos, regex):
  if type(textos) == str:
    return regex.sub('',textos)
  else:
    return [regex.sub('', texto) for texto in textos]Tentei fazer uma aqui, mas não deu muito certo :'(. Como eu acerto isso?
def limpar_tag_code(textos,regex):
  regex_html = re.compile(r'<.*?>')
  if type(textos) == str:
    texto_com_tag = regex.sub('CODE',textos)
  else:
    texto_com_tag = [regex.sub('CODE', texto) for texto in textos]
  if type(texto_com_tag) == str:
    return regex_html.sub('',texto_com_tag)
  else:
    return [regex_html.sub('', texto) for texto in texto_com_tag]