Suppose we have a string s with only lowercase or uppercase letters not numbers. We have to check whether both lowercase and uppercase letters follow the same order respectively or not. So, if a letter occurs more than once in lowercase then the occurrence of the same character in the uppercase will be same.
So, if the input is like s = "piPpIePE", then the output will be True, as occurrences of lowercase letters and uppercase letters are same, and they are in the same order in lowercase and uppercase also.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def solve(s) : lowercase = "" uppercase = "" for i in range(len(s)) : if ord(s[i]) >= 65 and ord(s[i]) <= 91 : uppercase += s[i] else : lowercase += s[i] to_upper = lowercase.upper() return to_upper == uppercase s = "piPpIePE" print(solve(s))