← Back to challenges

Index Shuffle

PythonHardstringsloops

Instructions

Write a function that takes all even-indexed characters and odd-indexed characters from a string and concatenates them together.

To illustrate:

index_shuffle("abcd") ➞ "acbd"
// "ac" (even-indexed) + "bd" (odd-indexed)

Examples

index_shuffle("abcdefg") ➞ "acegbdf"

index_shuffle("holiday") ➞ "hldyoia"

index_shuffle("maybe") ➞ "myeab"

Notes

0 should be treated as an even number.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Product of All Odd Integers