From 04bc8f01dd81b8f4ca68e470d046fcb571b4d3d0 Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Thu, 23 Jun 2022 19:47:29 +0300 Subject: [PATCH] Wave (#6061) * Added censor function * Added censor code * Added comments to the code * modified censor function * added decrypt function * added cypher and decypher functions, deleted censor and decrypt functions * Deleted decrypt.py * Deleted censor.py * edited the crypt and decrypt files * Update cypher_txt.py * Remove the endline in cypher.py * Removed the print at the end of decypher.py * added 4 new algorithms * added tests to the four files * added type hints for the function variables * Deleted decode message * Deleted code message * Welford average algorithm * added average welford algorithm * is_narcissistic added * added a descriptive name * added max_sectors algorithm * added find_unique * added wave algorithm * deleting average_welford [ in the wrong pr ] * deleting is_narcissistic [ is in the wrong pr ] * deleting max_sectors [ is in the wrong pr ] * deleting find_unique [ is in the wrong pr ] * deleting censor [ is in the wrong pr ] * deleting decrypt [ is in the wrong pr ] * fixed wave.py fixed indentation and followed the bots reccomendations * fixed wave.py again * fixing wave.py for the third time. * fixing wave.py * merging strings/wave.py merging the suggestion Co-authored-by: John Law Co-authored-by: John Law --- strings/wave.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 strings/wave.py diff --git a/strings/wave.py b/strings/wave.py new file mode 100644 index 000000000..69d534432 --- /dev/null +++ b/strings/wave.py @@ -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()