We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1127393 commit bca3c72Copy full SHA for bca3c72
strings/reverse_letters.py
@@ -0,0 +1,19 @@
1
+def reverse_letters(input_str: str) -> str:
2
+ """
3
+ Reverses letters in a given string without adjusting the position of the words
4
+ >>> reverse_letters('The cat in the hat')
5
+ 'ehT tac ni eht tah'
6
+ >>> reverse_letters('The quick brown fox jumped over the lazy dog.')
7
+ 'ehT kciuq nworb xof depmuj revo eht yzal .god'
8
+ >>> reverse_letters('Is this true?')
9
+ 'sI siht ?eurt'
10
+ >>> reverse_letters("I love Python")
11
+ 'I evol nohtyP'
12
13
+ return " ".join([word[::-1] for word in input_str.split()])
14
+
15
16
+if __name__ == "__main__":
17
+ import doctest
18
19
+ doctest.testmod()
0 commit comments