python 在一个list里用while loop计算1的长度

给定一个整数的列表,返回从头开始的最长的1的长度
(不能使用break and continue)


# lists=[1,1,0]
# lists=[0,1,0]
lists=[1,0,1]
mark=0
for  i  in  range(len(lists)):
    if  i==mark and lists[i]==1:
        mark+=1
print(mark)



img

img

img