Advertisement
alex0sunny

repeat

Dec 18th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. def repeat(s):
  2.     for i in range(len(s) // 2):
  3.         if s[0] == s[-1-i] and s[i] == s[-1] and len(s) % (i+1) == 0 and \
  4.                 s[:i+1] == s[-1-i:] and (len(s) // (i+1)) * s[:i+1] == s:
  5.             return len(s) // (i+1)
  6.     return 1
  7.  
  8.  
  9. s = input()
  10. print(repeat(s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement