avatar Bite 373. Reverse only Letters

Given a string, reverse only the English letters (lowercase or uppercase) in the string, leaving all non-English letters and other characters (e.g. numbers) in their original position. 

Example:

>>> from  reverse_letters import reverse_letters
>>> string = "ab-cd"
>>> reverse_letters(string)
'dc-ba'

Example 2:

>>> from  reverse_letters import reverse_letters
>>> string = "ab5DEf"
>>> reverse_letters(string)
'fE5Dba'

Example 3:

>>> from  reverse_letters import reverse_letters
>>> string = "a-bC-dEf-ghIj"
>>> reverse_letters(string)
'j-Ih-gfE-dCba'

Keep calm and code in Python!

Login and get coding
go back Beginner level
Bitecoin 2X

36 out of 41 users completed this Bite.
Will you be the 37th person to crack this Bite?
Resolution time: ~41 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 6.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help