Find the shortest whole repetitive substring
Why not use a regular expression?

&gt;&gt;&gt; import re
&gt;&gt;&gt; len(re.match(r'(.+?)\1*$', 'catcatcat').group(1))
3


This has runtime \$Θ(n^2)\$, same as the code in the post, but it's a lot shorter.