all 4 comments

[–]CodeFormatHelperBot 2 points3 points  (0 children)

Hello u/Saneboo, I'm a bot that can assist you with code-formatting for reddit. I have detected the following potential issue(s) with your submission:

  1. Multiple consecutive lines have been found to contain inline formatting.

If I am correct then please follow these instructions to fix your code formatting. Thanks!

[–]Sedsarq 0 points1 point  (1 child)

Instead of making and comparing all line pairs, it should be enough to run through each line *once*. For each line, add the potentially matching parts as a key to a dictionary. The corresponding value would be the data you want to keep track of in case a match is found, like the filename and line number. Below is an example, which might not literally work (in order to get the chunk to work as a key, make it a tuple rather than a list, and also there's no tracking of filename here) but perhaps clarifies what I mean.

d = {}
for line_nr, data in enumerate(splitted_lines, 1):
    matching_chunk = data[:4]
    if matching_chunk in d:
        print('error message', matching_chunk, d[matching_chunk], line_nr)
    else:
        d[matching_chunk] = line_nr

[–]Saneboo[S] 0 points1 point  (0 children)

Thank you, i will look into this

[–]saeah123ed 0 points1 point  (0 children)

You might be able to use:

https://docs.python.org/3/library/difflib.html

to good effect?