← Back to challenges

AlTeRnAtInG cApS

PythonHardconditionsformattingstrings

Instructions

Create a function that alternates the case of the letters in a string (known as Spongecase).

Examples

alternating_caps("Hello") ➞ "HeLlO"

alternating_caps("How are you?") ➞ "HoW aRe YoU?"

alternating_caps("OMG this website is awesome!") ➞ "OmG tHiS wEbSiTe Is AwEsOmE!"

Notes

  • The first letter should always be UPPERCASE.
  • Ignore spaces.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.