← Back to challenges

Split a String Based on Vowels and Consonants

PythonHardcontrol_flowconditionsfunctional_programmingregex

Instructions

Write a function that takes a string, breaks it up and returns it with vowels first, consonants second. For any character that's not a vowel (like special characters or spaces), treat them like consonants.

Examples

split("abcde") ➞ "aebcd"

split("Hello!") ➞ "eoHll!"

split("What's the time?") ➞ "aeieWht's th tm?"

Notes

  • Vowels are a, e, i, o, u.
  • Define a separate is_vowel() function for easier to read code (recommendation).
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Let's Sort This List!