From 7070311f192c1961b975aeb9d2d9885736a58c81 Mon Sep 17 00:00:00 2001 From: sauravb10 Date: Sun, 30 Oct 2022 11:37:14 +0530 Subject: [PATCH] Added function to find the plaindrome --- palindrome.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 palindrome.py diff --git a/palindrome.py b/palindrome.py new file mode 100644 index 0000000000..7239156d40 --- /dev/null +++ b/palindrome.py @@ -0,0 +1,32 @@ +# Recursive function to check if a +# string is palindrome +def isPalindrome(s): + + # to change it the string is similar case + s = s.lower() + # length of s + l = len(s) + + # if length is less than 2 + if l < 2: + return True + + # If s[0] and s[l-1] are equal + elif s[0] == s[l - 1]: + + # Call is palindrome form substring(1,l-1) + return isPalindrome(s[1: l - 1]) + + else: + return False + +# Driver Code +s = "MalaYaLam" +ans = isPalindrome(s) + +if ans: + print("Yes") + +else: + print("No") +