strings.reverse_letters

Functions

reverse_letters(→ str)

Reverse all words that are longer than the given length of characters in a sentence.

Module Contents

strings.reverse_letters.reverse_letters(sentence: str, length: int = 0) str

Reverse all words that are longer than the given length of characters in a sentence. If unspecified, length is taken as 0

>>> reverse_letters("Hey wollef sroirraw", 3)
'Hey fellow warriors'
>>> reverse_letters("nohtyP is nohtyP", 2)
'Python is Python'
>>> reverse_letters("1 12 123 1234 54321 654321", 0)
'1 21 321 4321 12345 123456'
>>> reverse_letters("racecar")
'racecar'