You will be given a string that can contain lowercase letters, uppercase letters, or spaces. You have to turn the vowels (a, e, i, o, u) in the string to upper case and consonants to lower case. This applies whether or not the letter was originally upper case or lower case. Spaces remain as is. Note that "y" is a consonant.


Hello World -> hEllO wOrld
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVXWYZ -> AbcdEfghIjklmnOpqrstUvwxyz AbcdEfghIjklmnOpqrstUvxwyz


  • The input string can contain letters A to Z, lowercase or uppercase, and spaces.


The string


The formatted string (Vowels uppercase and consonants lowercase).

  • 1
    \$\begingroup\$ Why on many challenges is "y" counted as a consonant ? \$\endgroup\$
    – CreaZyp154
    Feb 16, 2022 at 13:40
  • \$\begingroup\$ Because it is a consonant. (<pedantic> unless you're using international phonetic alphabet, where it's the front-high-rounded vowel /y/</pedantic>) \$\endgroup\$
    – bigyihsuan
    Feb 16, 2022 at 15:35
  • \$\begingroup\$ @bigyihsuan It's a bit more complicated than that. Wikipedia says: "In the English writing system, it mostly represents a vowel and seldom a consonant." As a child, I was taught that the vowels were "A, E, I, O, U, and sometimes Y," which could lead to viewing Y as "not really a vowel" because it's not always a vowel. Y is also a consonant in some very common words like "yes" and "you." But these are just guesses; I'm not entirely sure why Y is often not considered a vowel in coding challenges. \$\endgroup\$
    – DLosc
    Feb 16, 2022 at 18:44

62 Answers 62

1 2

YASEPL, 155 147 145 140 bytes


Python 3, 82 bytes

f=lambda c:c.upper()if c in 'aeiou'else c.lower();lambda s:''.join(map(f,list(s)))
1 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.