FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TheAlgorithms-Python/strings/reverse_letters.py at master · windNight/TheAlgorithms-Python · GitHub
windNight
/
TheAlgorithms-Python
Public
forked from
TheAlgorithms/Python
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TheAlgorithms-Python
/
strings
/
reverse_letters.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
19 lines (16 loc) · 604 Bytes
Breadcrumbs
TheAlgorithms-Python
/
strings
/
reverse_letters.py
Copy path
File metadata and controls
19 lines (16 loc) · 604 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def
reverse_letters
(
input_str
:
str
)
->
str
:
"""
Reverses letters in a given string without adjusting the position of the words
>>> reverse_letters('The cat in the hat')
'ehT tac ni eht tah'
>>> reverse_letters('The quick brown fox jumped over the lazy dog.')
'ehT kciuq nworb xof depmuj revo eht yzal .god'
>>> reverse_letters('Is this true?')
'sI siht ?eurt'
>>> reverse_letters("I love Python")
'I evol nohtyP'
"""
return
" "
.
join
([
word
[::
-
1
]
for
word
in
input_str
.
split
()])
if
__name__
==
"__main__"
:
import
doctest
doctest
.
testmod
()
Back
|
FazBrowse Home
|
New Git URL