Python EOFerror,binarygap

时间:2018-06-20 08:47:24

标签: python python-3.x eoferror

stop()

输出是这样的

def dectobin(n):

    return int(bin(n)[2:])
    print(int(bin(n)[2:]))

def solution(r):

    k = dectobin(r)
    print(k)
    m = str(k)
    maxgap=0
    running=0
    for i in (0,len(m)-1):
        if m[i] == 0:
            running = running+1
        elif m[i] == 1:
            if running > maxgap:
                maxgap = running
                running = 0
    print(maxgap)

x = input("give the number")
solution(x)

为什么?

0 个答案:

没有答案