From 629b914fcc1e7616238019533e15701571afaa17 Mon Sep 17 00:00:00 2001 From: Inbaselvan-ayyanar <141208152+Inbaselvan-ayyanar@users.noreply.github.com> Date: Mon, 5 May 2025 22:02:54 +0530 Subject: [PATCH] Update String_Palindrome.py more efficient --- String_Palindrome.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/String_Palindrome.py b/String_Palindrome.py index 6b8302b6477..ab4103fd863 100644 --- a/String_Palindrome.py +++ b/String_Palindrome.py @@ -1,15 +1,15 @@ # Program to check if a string is palindrome or not -my_str = 'aIbohPhoBiA' +my_str = input().strip() # make it suitable for caseless comparison my_str = my_str.casefold() # reverse the string -rev_str = reversed(my_str) +rev_str = my_str[::-1] # check if the string is equal to its reverse -if list(my_str) == list(rev_str): +if my_str == rev_str: print("The string is a palindrome.") else: print("The string is not a palindrome.")