parts [terminology]
Terminology¶
Usage¶
- Use for pieces that will later be joined into one string or result.
- It is preferable to
reswhen construction explicitly occurs through concatenation. - Individual entries may include signs, separators, digits, or encoded runs.
for _ in range(n - 1):
parts = []
i = 0
while i < len(s):
j = i
while j < len(s) and s[j] == s[i]:
j += 1
parts.append(str(j - i))
parts.append(s[i])
i = j
s = "".join(parts)
See 38. Count and Say.