← Back to challenges

Reverse the String (with a catch)

PythonHardstringsformatting

Instructions

Create a function that takes a string and returns the reversed string. However there's a few rules to follow in order to make the challenge interesting:

  • The UPPERCASE/lowercase positions must be kept in the same order as the original string (see example #1 and #2).
  • Spaces must be kept in the same order as the original string (see example #3).

Examples

special_reverse_string("Innokodakademija") ➞ "Tibade"

special_reverse_string("UPPER lower") ➞ "REWOL reppu"

special_reverse_string("1 23 456") ➞ "6 54 321"

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.