Suppose we have a string s. We have to check whether characters in s are in alphabetical order or not.
So, if the input is like s = "mnnooop", then the output will be True.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def solve(s): char_arr = list(s) char_arr.sort() return char_arr == list(s) s = "mnnooop" print(solve(s))