Python recursion returns None

前端 未结 2 1486
野的像风
野的像风 2021-01-29 07:38

This will be really funny... Given following python codes:

def getBinary(binaryInput, kSize, beginBit):
    if int(binaryInput[beginBit + kSize-1])=         


        
2条回答
  •  太阳男子
    2021-01-29 07:55

    The code is missing in the else part:

    def getBinary(binaryInput, kSize, beginBit):
        if int(binaryInput[beginBit + kSize-1])==1:
            print 'entered!!!'
            shortE = binaryInput[beginBit:kSize+beginBit]
            print 'shortE is now: ', shortE
            print 'kSize is now: ', kSize
            return (shortE,kSize)
        else :
            print 'else entered...'
            kSize -=1
            return getBinary(binaryInput, kSize, beginBit)
            # ^^^^
    

提交回复
热议问题