a53

SubStringRep_python3

a53
Sep 15th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. import re
  2.  
  3. REPEATER = re.compile(r"(.+?)\1+$")
  4.  
  5. def repeated(s):
  6. match = REPEATER.match(s)
  7. return match.group(1) if match else -1
  8.  
  9. n=int(input())
  10. for i in range(0,n):
  11. s=str(input())
  12. print(repeated(s))
Add Comment
Please, Sign In to add comment