(old_text, new_indent)
return new_text
Perform re-indentation of the text ``old_text`` with new indent ``new_indent``.

    :param old_text: Multi-line string for which re-indentation is performed
    :param new_indent: New indent
    :return: New multi-line text
Perform re-indentation of the text ``old_text`` with new indent ``new_indent``.
Perform re - indentation of the text old_text with new indent new_indent .
def reindent(old_text, new_indent):
    """
    Perform re-indentation of the text ``old_text`` with new indent ``new_indent``.

    :param old_text: Multi-line string for which re-indentation is performed
    :param new_indent: New indent
    :return: New multi-line text
    """

    if old_text == '':
        return ' '*new_indent

    old_indent = get_indent(old_text)
    lines = old_text.split('\n')
    new_text = ''
    for line in lines:
        if line.strip() == '':
            new_text += '\n'
        else:
            line = line[old_indent:]
            new_text += ' '*new_indent + line + '\n'

    # If ``old_text`` has no ``'\n'`` in the end, remove it too from the ``new_text``
    if old_text[-1] != '\n':
        new_text = new_text[:-1]

    return new_text
def reindent ( old_text , new_indent ) : if old_text == '' : return ' ' * new_indent old_indent = get_indent ( old_text ) lines = old_text . split ( '\n' ) new_text = '' for line in lines : if line . strip ( ) == '' : new_text += '\n' else : line = line [ old_indent : ] new_text += ' ' * new_indent + line + '\n' # If ``old_text`` has no ``'\n'`` in the end, remove it too from the ``new_text`` if old_text [ - 1 ] != '\n' : new_text = new_text [ : - 1 ] return new_text