You are viewing a single comment's thread. Return to all comments →
Sometimes you need to try to solve the problem with your onw logic. and here is mine, , whats do you think champs ?
s = '1222311' count = 1 for i in range(1, len(s)): # if i+1 < len(s): # print(i, i-1) if s[i] == s[i-1]: count += 1 else: print(f"({count}, {s[i-1]})", end=' ') count = 1 print(f"({count}, {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 →
Sometimes you need to try to solve the problem with your onw logic. and here is mine, , whats do you think champs ?