本地连全0全1都试过,就是不知道哪里的问题?
代码如下:
lists = []
l, y = 0, 0
temp = input()
lists.append(len(temp))
for i in range(1, lists[0]):
temp += input()
if temp[0] != '0':
lists.append(0)
for i in list(temp):
if i == '0':
l += 1
else:
y += 1
if i == '0' and y > 0:
lists.append(y)
y = 0
if i == '1' and l > 0:
lists.append(l)
l = 0
lists.append(l) if l > 0 else lists.append(y)
print(' '.join(list(map(str, lists))), end=' ')