Untitled

 avatar
unknown
python
3 years ago
589 B
5
Indexable
from typing import List


def upakuj(input_path: str = "Input.txt"):

    lines: List

    with open(input_path, encoding="utf-8") as f:
        lines = f.readlines()

    n = 1
    output_str = ""
    for line in lines: 
        for idx, c in enumerate(line):
            if idx + 1 >= len(line):
                output_str += f"{c}{n}"
            elif c == line[idx+1]:
                n += 1
            elif c != line[idx+1]:
                output_str += f"{c}{n}"
                n = 1


    with open("output.txt", "w", encoding="utf-8") as f:
        f.write(output_str)

upakuj()
Editor is loading...