Advertisement
Dimitar_Borisov

TODO: Check if the text is a palindrome (ignoring case and spaces)

May 22nd, 2025
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. text = input("Enter the text: ")
  2.  
  3. text_lower = [s.lower() for s in text]
  4. # text_lower = text_lower.replace(" ", "")
  5.  
  6. i = 0
  7. j = len(text_lower) - 1
  8. is_palindrome = True
  9.  
  10. while i < j:
  11.     if text_lower[i] != text_lower[j]:
  12.         is_palindrome = False
  13.         break
  14.  
  15.     i += 1
  16.     j -= 1
  17.  
  18. if is_palindrome:
  19.     print("Yes")
  20. else:
  21.     print("No")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement