← Back to challenges

Reverse Letters, Keep Numbers in Place

PythonHardstringslogicformattingloops

Instructions

Create a function that reverses letters in a string but keeps digits in their current order.

Examples

reverse("ab89c") ➞ "cb89a"

reverse("jkl5mn923o") ➞ "onm5lk923j"

reverse("123a45") ➞ "123a45"

Notes

N/A

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