A late review, but ...
You are trying to solve the problem as one monolithic block. It is often better to break the problem down into individual steps.
In this case, you have a long string of digits, and you want to extract sub-sequences of digits of a specific length.
For each sub-sequence item you find, you want to remember the position you found it at, and if you've seen it before.
And you might want to stop when you've found the first one.
You can take these smaller operations and compose them together.
The following reworked code demonstrates this approach, along with type-hints, docstrings, and a doctest, which are always good things to have.
from typing import Iterable, Tuple
def sliding_window(subject: str, window: int) -> Iterable[str]:
"""
Return successive substrings of a given length, moving forward
through the string:
>>> list(sliding_window("3.14159", 2))
['3.', '.1', '14', '41', '15', '59']
>>> list(sliding_window("3.14159", 3))
['3.1', '.14', '141', '415', '159']
"""
for i in range(len(subject) - window + 1):
yield subject[i:i+window]
def repeats(sequence: Iterable[str]) -> Tuple[str, int, int]:
"""
Scan through a sequence of items, recording the location of each item,
and when a duplication is found, return the item along with
its previous and current position.
>>> list(repeats(["xy", "xyz", "ab", "xy", "ab", "ab"]))
[('xy', 0, 3), ('ab', 2, 4), ('ab', 4, 5)]
"""
positions = {}
for pos, item in enumerate(sequence):
prev = positions.get(item)
if prev is not None:
yield item, prev, pos
positions[item] = pos
def first_repeat(subject, length):
"""
Scan through a string, and find the first repeated substring of
a given length. Returns the substring, first position and second position.
>>> first_repeat("The quick brown fox jumped over the lazy dog", 2)
('he', 1, 33)
"""
return next(repeats(sliding_window(subject, length)))
def main():
pi = "3.141592653589793238462643383279502884197169399375105820974944592"
pi_fraction = pi[2:]
print(first_repeat(pi_fraction, 1))
print(first_repeat(pi_fraction, 2))
print(first_repeat(pi_fraction, 3))
if __name__ == '__main__':
import doctest
doctest.testmod()
main()