The problem of counting the number of elements and listing them as strings.
Using the Python built-in library, you can solve it as follows:
from collections import Counter
from itertools import chain
def compress(value):
counter = Counter(value)
return "".join(str(v) for v in chain.from_iterable(counter.items()))
assert compress("aabbbccccddaa") == "a4b3c4d2"
a = list(input())
def k(c):
b = 0
for i in range(len(a)-1):
b += a.count(a[i])
For j in range(len(a), 0, -1):#Length????
if a.count(a[i]) != 1:
del a[i]
return b == 1
print(a[i]+b,end="")
print(k(a))
I've been trying to fix it, and now I'm stopping here and whining. What should I fix? ㅠ<
© 2024 OneMinuteCode. All rights reserved.