'How would you write a recursive function that determines if the characters of a string are in an ascending order?

This is what I have so far...

def isAscending(s):
  s = "".join(character.lower() for character in s if character.isalpha())
  
  if len(s) <= 1:
    return True
  if s[0] <= s[1]:
    return isAscending(s[1:])
  return False

When I run something like 'abcCEF' it should return False but it's returning True.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source