MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / wave

Function wave

strings/wave_string.py:1–16  ·  view source on GitHub ↗

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']

(txt: str)

Source from the content-addressed store, hash-verified

1def wave(txt: str) -> list:
2 """
3 Returns a so called 'wave' of a given string
4 >>> wave('cat')
5 ['Cat', 'cAt', 'caT']
6 >>> wave('one')
7 ['One', 'oNe', 'onE']
8 >>> wave('book')
9 ['Book', 'bOok', 'boOk', 'booK']
10 """
11
12 return [
13 txt[:a] + txt[a].upper() + txt[a + 1 :]
14 for a in range(len(txt))
15 if txt[a].isalpha()
16 ]
17
18
19if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected