<doocs>1404.Number of Steps to Reduce a Number in Binary Representation to One_1.py
def numSteps( s: str) -> int:
    carry = False
    ans = 0
    for c in s[:0:-1]:
        if carry:
            if c == '0':
                c = '1'
                carry = False
            else:
                c = '0'
        if c == '1':
            ans += 1
            carry = True
        ans += 1
    if carry:
        ans += 1
    return ans
def sample_funcname ( var_0 : str ) -> int :
    var_4 = False
    var_6 = 0
    for var_8 in var_0 [ : 0 : - 1 ] :
        if var_4 :
            if var_8 == '0' :
                var_8 = '1'
                var_4 = False
            else :
                var_8 = '0'
        if var_8 == '1' :
            var_6 += 1
            var_4 = True
        var_6 += 1
    if var_4 :
        var_6 += 1
    return var_6
