forked from TheAlgorithms/Python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwave.py
More file actions
Latest commit
20 lines (17 loc) · 437 Bytes
/
Copy pathwave.py
File metadata and controls
20 lines (17 loc) · 437 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
defwave(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 :]
forainrange(len(txt))
iftxt[a].isalpha()
]
if__name__=="__main__":
__import__("doctest").testmod()