You are viewing a single comment's thread. Return to all comments →
s=input() count=1 for i in range(1,len(s)): if s[i]==s[i-1]: count+=1 else: print((count,int(s[i-1])),end=" ") count=1 print((count,int(s[-1])))
Seems like cookies are disabled on this browser, please enable them to open this website
Compress the String!
You are viewing a single comment's thread. Return to all comments →
s=input() count=1 for i in range(1,len(s)): if s[i]==s[i-1]: count+=1 else: print((count,int(s[i-1])),end=" ") count=1 print((count,int(s[-1])))