This code is definitely wrong, but it passes all the cases.
def repeatedSubstringPattern(self, str) for i in range(2, len(str) + 1): if len(str) % i == 0: s, d = 0, len(str) / i return str[s: s + d] == str[s + d: s + d * 2] return False
@ma390149401 You are right, if you don't mean "definitely wrong" is because it miss a colon in the first line. If the number of group is odd, it will return wrong answer, for example, "ababab" will return False.
@ma390149401 Test cases were added, now this solution gets Wrong Answer.