A = "AEJXKWKJSSSJKZJLJLEJSSLKXMPPLSSKKDNEMSMLDMMEPPLETFMM"
print Repeat_Letter : [PPL:16, JSS:10] --> What I want
String A is a string that lists random characters that I suggested. Some of them are repetitive string. Repeated string within long strings is "PPL" and "JSS" in string A, respectively. 16 is a distance between the letter "PPL", and 10 is the distance between "JSS". And finally, the goal is to automatically determine repeated words and to express the distance between these words as a list in python.
trigrams = [A[i:i+3] for i in range(len(A)-2)]
counts = collections.Counter(trigrams)
repeated = [trigram for trigram, count in counts.items() if count > 1]
Through this, I checked which word is repeated. However, I'm wondering how to get the distance of these discriminated words. For example, we don't know how to get the distance between "PPL" and other "PPL".