-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswapper.py
37 lines (29 loc) · 826 Bytes
/
swapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def swapper(p1,p2,leng):
"""Swapper
To Swap two letters and check whether the words are
suffering from palindrome Syndrome .
Args:
p1 (str) : [ Swappable 1 ]
p1 (str) : [ Swappable 2 ]
len (int) : [ Length of the word ]
"""
A = []
B = []
for i in range(leng):
if p1[i] != p2[i]:
A.append(p1[i])
B.append(p2[i])
if len(A) == len(B) == 0:
return True
if len(A) == len(B) == 2:
if A[0] == A[1] and B[0] == B[1]:
return True
return False
# Driver Code
# test@0
# A = input("Enter the 1st word : ")
# B = input("Enter the 2nd word : ")
# if(swapper(A, B, len(A))):
# print("The words are swappable")
# else:
# print("The words are not Swappable")