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

30 out of 35 users completed this Bite.
Will you be the 31st person to crack this Bite?
Resolution time: ~30 min. (avg. submissions of 5-240 min.)

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

Ask for Help