Zigzag capitals
Inputs
text is 0 to 20 lowercase letters (a to z).
Your tasks
- Create an empty string
result. - Use a loop over the positions of
text. Add the character in capital letters when its position is even (0, 2, 4, and so on), and as it is when the position is odd. - Complete
zigzagso it returnsresult. Return it, do not print it.
Example
With text = "zigzag", zigzag returns "ZiGzAg".
Rules
- Positions start at 0.
Test data
TEST DATA 1: text is "zigzag"
TEST DATA 2: text is ""
Practice focus
Text is just a list of characters, so everything you know about lists applies. String problems in interviews are array problems with letters.