Ctrl K

Vowel-Balanced Halves

Easy
You are given a string text of even length made of English letters. Cut it exactly in the middle into two halves of equal length. Return True if both halves contain the same number of vowels and False otherwise. The vowels are a, e, i, o, u, in lowercase or uppercase. Every occurrence of a vowel counts separately.
Example 1
text='rainbows' → False

"rain" and "bows": the first half has two vowels (a, i), the second has one (o).

Example 2
text='OpenAI' → True

"Ope" and "nAI": two vowels in each half, regardless of case.

Example 3
text='xy' → True

Neither half has a vowel: 0 and 0 is a tie.

Constraints
  • 2 ≤ len(text) ≤ 1000
  • len(text) is even
  • text consists of uppercase and lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsNote From Clipped Letters EasyFirst One-Off Letter EasyWords Heard Only Once EasyWords From Letter Tiles EasyBalloon Signs From Letters Easy
loading Python…
Input
text='rainbows'
Expected
False

Run checks the first 3 tests in your browser. Submit checks all 105 tests on the server, hidden ones included.