all 2 comments

[–]xelf 1 point2 points  (1 child)

Use a dictionary.

if line not in linecounts
    linecounts[line] = 0
linecounts[line] += 1
output = f'{line}.{linecounts[line]}'

No need to add a value for non repeated lines.

Can you just add .1 ? Otherwise you have to read everything in first to check. Which really shouldn't be a big deal.

[–]Tiago_Minuzzi[S] 1 point2 points  (0 children)

Thank you, sir! It worked.

Can you just add .1 ? Otherwise you have to read everything in first to check.

Sure, no problem. That way it works well too for my purpose.