Advertisement
Josif_tepe

Untitled

Oct 14th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. def main():
  2.     s = input("Input a string: ")
  3.     i = 0
  4.     j = len(s) - 1
  5.  
  6.     ok = True
  7.     while i < j:
  8.         if s[i] != s[j]:
  9.             ok = False
  10.             break
  11.         i += 1
  12.         j -= 1
  13.  
  14.     if ok:
  15.         print("PALINDROME")
  16.     else:
  17.         print("NOT A PALINDROME")
  18.  
  19.  
  20. if __name__ == "__main__":
  21.     main()
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement