Program to check string is palindrome with lowercase characters or not in Python

Suppose we have alphanumeric string s. It can hold both uppercase or lowercase letters. We have to check whether s is a palindrome or not considering only the lowercase alphabet characters.

So, if the input is like s = "rLacHEec0a2r8", then the output will be True because the string contains "racecar" in lowercase, which is a palindrome.

To solve this, we will follow these steps −

  • x := blank string

  • for each character i in s, do

    • if i is in lowercase, then

      • x := x concatenate i

  • return true when x is palindrome, otherwise false


Let us see the following implementation to get better understanding

def solve(s):
   x = ""
   for i in s:
      if i.islower():
         x += i

   return x == x[::-1]

s = "rLacHEec0a2r8"