Your job is to write a function which increments a string, to create a new string.
- If the string already ends with a number, the number should be incremented by 1.
- If the string does not end with a number. the number 1 should be appended to the new string.
Examples:
`foo -> foo1`
`foobar23 -> foobar24`
`foo0042 -> foo0043`
`foo9 -> foo10`
`foo099 -> foo100`
*Attention: If the number has leading zeros the amount of digits should be considered.*
def increment_string(strng):
    if not strng:
        return "1"
    end_idx = len(strng) - 1
    digit_str = ''
    while end_idx >= 0:
        if not strng[end_idx].isdigit():
            break
        digit_str = strng[end_idx] + digit_str
        end_idx -= 1

    if not digit_str.isdigit():
        increment_str = "1"
    elif digit_str[0] != '0':
        increment_str = str(int(digit_str) + 1)
    elif int(digit_str) == 0:
        increment_str = (len(digit_str) - 1) * '0' + '1'
    else:
        len_digit_str = len(digit_str)
        start_idx = 0
        while start_idx < len_digit_str:
            if digit_str[start_idx] != '0':
                break
            start_idx += 1
        increment = str(int(digit_str[start_idx:]) + 1)
        increment_str = (len_digit_str - len(increment)) * '0' + increment

    return strng[0:end_idx+1]+increment_str

def increment_string(strng):
    if not strng:
        return "1"
    end_idx = len(strng) - 1
    digit_str = ''
    while end_idx >= 0:
        if not strng[end_idx].isdigit():
            break
        digit_str = strng[end_idx] + digit_str
        end_idx -= 1

    if not digit_str.isdigit():
        increment_str = "1"
    elif digit_str[0] != '0':
        increment_str = str(int(digit_str) + 1)
    elif int(digit_str) == 0:
        increment_str = (len(digit_str) - 1) * '0' + '1'
    else:
        len_digit_str = len(digit_str)
        start_idx = 0
        while start_idx < len_digit_str:
            if digit_str[start_idx] != '0':
                break
            start_idx += 1
        increment = str(int(digit_str[start_idx:]) + 1)
        increment_str = (len_digit_str - len(increment)) * '0' + increment

    return strng[0:end_idx+1]+increment_str
