From 16424d1f23e212f4ef11feebd1f6d8950e835f58 Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Fri, 5 Jan 2024 22:14:36 +0100 Subject: [PATCH] Added asap() and rsap() functions. These functions are so simple that I am too lazy to explain their tasks. --- text.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/text.py b/text.py index 678685b..b4fc968 100644 --- a/text.py +++ b/text.py @@ -90,5 +90,26 @@ class Log: return self.log +def asap(old: str, add: str, position: int): + """ + ASAP = Add String At Position + + (0 is the first character.) + """ + + return old[:position] + add + old[position:] + + +def rsap(old: str, add: str, position: int): + """ + RSAP = Replace String At Position + + (0 is the first character.) + """ + + return old[:position] + add + old[position + 1:] + + if __name__ == "__main__": example() + print(rsap("bfa", "l", 1))