
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Check whether the vowels in a string are in alphabetical order or not in Python
Suppose we have a string s. We have to check whether the vowels present in s are in alphabetical order or not.
So, if the input is like s = "helloyou", then the output will be True as vowels are e, o, o, u all are in alphabetical order.
To solve this, we will follow these steps −
- character := character whose ASCII is 64
- for i in range 0 to size of s - 1, do
- if s[i] is any one of ('A','E','I','O','U','a','e','i','o','u'), then
- if s[i] < character, then
- return False
- otherwise,
- character := s[i]
- if s[i] < character, then
- if s[i] is any one of ('A','E','I','O','U','a','e','i','o','u'), then
- return True
Let us see the following implementation to get better understanding −
Example Code
def solve(s): character = chr(64) for i in range(len(s)): if s[i] in ['A','E','I','O','U','a','e','i','o','u']: if s[i] < character: return False else: character = s[i] return True s = "helloyou" print(solve(s))
Input
"helloyou"
Output
True
- Related Articles
- Check if the characters of a given string are in alphabetical order in Python
- Check whether a string is valid JSON or not in Python
- Check whether the frequencies of all the characters in a string are prime or not in Python
- Program to check whether two string arrays are equivalent or not in Python
- C++ Program to check string is strictly alphabetical or not
- Check whether the given numbers are Cousin prime or not in Python
- Check whether the Average Character of the String is present or not in Python
- Program to check whether parentheses are balanced or not in Python
- Check if string follows order of characters defined by a pattern or not in Python
- How to Check Whether a String is Palindrome or Not using Python?
- Python program to check whether a given string is Heterogram or not
- Program to check whether elements frequencies are even or not in Python
- Program to check whether two sentences are similar or not in Python
- Why are the keys on the keyboard not arranged in alphabetical order?
- Check if all the 1s in a binary string are equidistant or not in Python

Advertisements