<jupyter_start><jupyter_text>You are given a string,"S" . Suppose a character 'c' occurs consecutively X times in the string. Replace these consecutive occurrences of the character '(X,c)' with  in the string.<jupyter_code>s = '1222311'
from itertools import groupby
print(*[(len(list(c)), int(k)) for k, c in groupby(s)])
for c, items in groupby(s):
    print(tuple([len(list(items)),int(c)]), end=' ')
for i, n in groupby(s):
    a = list(n)  
    print(a)
    #print("(", len(a), ", ", a[0], ")", end = " ", sep = "")
for k, g in groupby(s):
    print("({}, {})".format(len(list(g)), k), end=" ")<jupyter_output>(1, 1) (3, 2) (1, 3) (2, 1)
{'fraction_non_alphanumeric': 0.21495327102803738, 'fraction_numerical': 0.024922118380062305, 'mean_word_length': 4.543103448275862, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '115957', 'license': 'Apache-2.0', 'n_tokens_mistral': 257, 'n_tokens_neox': 248, 'n_words': 77, 'path': 'notebooks/Compress the String!.ipynb', 'repo_name': 'neso613/python_coding', 'size': '642'}