def subat ( orig , index , replace ) : return "" . join ( [ ( orig [ x ] if x != index else replace ) for x in range ( len ( orig ) ) ] )
python string replace based on position
Substitutes the replacement string / character at the given index in the given string returns the modified string .
def subat(orig, index, replace):
    """Substitutes the replacement string/character at the given index in the
    given string, returns the modified string.

    **Examples**:
    ::
        auxly.stringy.subat("bit", 2, "n")
    """
    return "".join([(orig[x] if x != index else replace) for x in range(len(orig))])