From b42c42d61cb62cf8bac8b2314af43bd164464bc9 Mon Sep 17 00:00:00 2001 From: Gaurav Dubey <56021774+gauravdubey110@users.noreply.github.com> Date: Fri, 8 Oct 2021 20:28:42 +0530 Subject: [PATCH] Create swapppp.py --- swapppp.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 swapppp.py diff --git a/swapppp.py b/swapppp.py new file mode 100644 index 0000000..6531289 --- /dev/null +++ b/swapppp.py @@ -0,0 +1,17 @@ +# Python3 code to demonstrate working of +# Swap Binary substring +# Using translate() + +# initializing string +test_str = "geeksforgeeks" + +# printing original string +print("The original string is : " + test_str) + +# Swap Binary substring +# Using translate() +temp = str.maketrans("geek", "abcd") +test_str = test_str.translate(temp) + +# printing result +print("The string after swap : " + str(test_str))