题解 | #字符串编码#
字符串编码
https://www.nowcoder.com/practice/56a487c342a64d2ea4c3a0b0144b42d0
a,b= input(),[] for i in a: if len(b) == 0: b.append(1) b.append(i) elif b[-1] != i: b.append(1) b.append(i) else: b[-2] = b[-2] + 1 print("".join(map(str, b)))
11行解决战斗