Sarcastic Caps

Python for AIMedium+10 XP+10

Sarcastic Caps

A meme generator writes text in "sarcastic caps": the letters flip between upper and lower case.

Task: write alternate_caps(text) that returns a new string where:

  • the character at every even position (0, 2, 4, ...) is uppercase;
  • the character at every odd position (1, 3, 5, ...) is lowercase.

Every character counts as a position, including spaces and punctuation. Those just stay the same when you change their case.

Examples

text = "hello"
returns 'HeLlO'
text = "PYTHON"
returns 'PyThOn'

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run