Compress the String!

  • + 0 comments

    Instead of importing itertools , we can write code below

    s= input() out=[] r=1 for i in range(len(s)): if i< len(s)-1 and s[i]==s[i+1]: r+=1 else: out.append((r,int(s[i]))) r=1 print(*[j for j in out ])