Question: Code Challenge: Assume that the variable text has already been defined with an arbitrary str value, consisting only of characters from the English alphabet. text

Code Challenge: Assume that the variable text has already been defined with an arbitrary str value, consisting only of characters from the English alphabet.
text =???
We will call the first index at which the number of vowels exceeds the number of consonants the critical index.
Print the critical index of text. If no critical index exists, print -1.
Note: You can assume that text is completely lowercase.
Note: Only "a","e","i","o","u" will be counted as vowels. All other letters are consonants.
Example (1): If text = "gooey", the critical index is 2, because that is the first index at which the number of vowels (2) exceeds the number of consonants (1).
Example (2): If text = "axe", the critical index is 0, because that is the first index at which the number of vowels (1) exceeds the number of consonants (0).
Example (3): If text = "carrot", there is no critical index because there is no index at which the number of vowels exceeds the number of consonants. In this case, print -1.
Sample Input:
gooey
Sample Output:
2
Write a program, test using stdin -> stdout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!