← Back to challenges

Move Capital Letters to the Front

PythonHardstringsformattingregex

Instructions

Create a function that moves all capital letters to the front of a word.

Examples

cap_to_front("hApPy") ➞ "APhpy"

cap_to_front("moveMENT") ➞ "MENTmove"

cap_to_front("shOrtCAKE") ➞ "OCAKEshrt"

Notes

Keep the original relative order of the upper and lower case letters the same.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Count Letters in a Word Search