mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 01:00:15 +00:00
21 lines
437 B
Python
21 lines
437 B
Python
|
def wave(txt: str) -> list:
|
||
|
"""
|
||
|
Returns a so called 'wave' of a given string
|
||
|
>>> wave('cat')
|
||
|
['Cat', 'cAt', 'caT']
|
||
|
>>> wave('one')
|
||
|
['One', 'oNe', 'onE']
|
||
|
>>> wave('book')
|
||
|
['Book', 'bOok', 'boOk', 'booK']
|
||
|
"""
|
||
|
|
||
|
return [
|
||
|
txt[:a] + txt[a].upper() + txt[a + 1 :]
|
||
|
for a in range(len(txt))
|
||
|
if txt[a].isalpha()
|
||
|
]
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
__import__("doctest").testmod()
|