-3
# Function that checks whether the vowel characters in a string are in alphabetical order or not

def areVowelsInOrder(s):

    n = len(s)

# ASCII Value 64 is less than all the alphabets so using it as a default value
    
    c = chr(64)

# check if the vowels in the string are sorted or not
    
    for i in range(0, n):

        if (s[i] == 'a' or s[i] == 'e' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u'):

            # if the vowel is smaller than the previous vowel
            
            if s[i] < c:
                return False
            else:

            # store the vowel
                c = s[i]

    return True


# Driver code
if __name__ == "__main__":

    s = "bbbeeaaddcc"

# check whether the vowel characters in a string are in alphabetical order or not
    if areVowelsInOrder(s):
        print("Yes")

    else:
        print("No")
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • Does this answer your question? [I'm getting an IndentationError. How do I fix it?](https://stackoverflow.com/questions/45621722/im-getting-an-indentationerror-how-do-i-fix-it) – wjandrea Dec 11 '21 at 05:15
  • BTW, please take the [tour] and read [ask]. For debugging help in the future, you'll need to make a [mre] including minimal code and the [full error message with traceback](https://meta.stackoverflow.com/q/359146/4518341). – wjandrea Dec 11 '21 at 05:15
  • Unfortunately Stack Overflow masks this particular error by converting tabs to 4 spaces. If you look at the [source](/revisions/72eadb74-0ab6-4151-b31e-e20589d8ca51/view-source), you'll see mixed tabs and spaces. – wjandrea Dec 11 '21 at 06:33
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Dec 17 '21 at 07:45

1 Answers1

-1

I tried it on google colab and it works fine :)

def areVowelsInOrder(s):
    n = len(s)
    c = chr(64)
    for i in range(0, n):
        if (s[i] == 'a' or s[i] == 'e' or s[i] == 'i' or s[i] == 'o' or s[i] == 'u'):
            if s[i] < c:
                return False
            else:
                c = s[i]
    return True

if __name__ == "__main__":
    s = "bbbeeaaddcc"
    if areVowelsInOrder(s):
        print("Yes")
    else:
        print("No")
  • Unfortunately Stack Overflow masks this particular error by converting tabs to 4 spaces. If you look at the [source](/revisions/72eadb74-0ab6-4151-b31e-e20589d8ca51/view-source), you'll see mixed tabs and spaces. – wjandrea Dec 11 '21 at 06:33