From 1d66c95f74cb7ca27145feca1117e7e6518258f3 Mon Sep 17 00:00:00 2001 From: sauravb10 Date: Mon, 31 Oct 2022 10:50:43 +0530 Subject: [PATCH] Add function to check if string is plaindrome --- palindrome.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 palindrome.py diff --git a/palindrome.py b/palindrome.py new file mode 100644 index 0000000..e38cc16 --- /dev/null +++ b/palindrome.py @@ -0,0 +1,19 @@ +# function to check string is +# palindrome or not +def isPalindrome(str): + + # Run loop from 0 to len/2 + for i in range(0, int(len(str)/2)): + if str[i] != str[len(str)-i-1]: + return False + return True + +# main function +s = "malayalam" +ans = isPalindrome(s) + +if (ans): + print("Yes") +else: + print("No") +