fork download
  1. t = int(input())
  2. s = input()
  3. r = s[::-1]
  4. f = True
  5.  
  6. if s == r:
  7. print(0)
  8. else:
  9. s*=2
  10. for i in range(len(r)):
  11. t=0
  12. while s[i+t]==r[t] and t <= len(r):
  13. t+=1
  14. if t == len(r):
  15. print(i)
  16. f = False
  17. break
  18.  
  19. if f:
  20. print(-1)
Runtime error #stdin #stdout #stderr 0.11s 23532KB
stdin
4
abac
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 12, in <module>
IndexError: string index out of range