mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Fix ruff (#12515)
* Empty commit * Fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * Fix * Fix * updating DIRECTORY.md --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
This commit is contained in:
20
strings/wave_string.py
Normal file
20
strings/wave_string.py
Normal file
@ -0,0 +1,20 @@
|
||||
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()
|
Reference in New Issue
Block a user