# Program to check if a string is palindrome or not my_str = 'aIbohPhoBiA' # make it suitable for caseless comparison my_str = my_str.casefold() # reverse the string rev_str = reversed(my_str) # check if the string is equal to its reverse if list(my_str) == list(rev_str):...
# Python program to check if a string is # palindrome or not # function to check palindrome string def isPalindrome(string): rev_string = string[::-1] return string == rev_string # Main code x = "Google" if isPalindrome(x): print(x,"is a palindrome string") else: print(x,"is...
Here is source code of the Python Program to check whether a string is a palindrome or not using recursion. The program output is also shown below. defis_palindrome(s):iflen(s)<1:returnTrueelse:ifs[0]==s[-1]:returnis_palindrome(s[1:-1])else:returnFalsea=str(input("Enter string:...
Python program to check the given date is valid or not# Importing datetime module import datetime # Input the date as integers and mapping # it to store the values to d, m, and y variables d, m, y = map(int, input("Enter date: ").split()) try: s = datetime.date(y, m, d)...
Check Palindrome in Python Using List Slicing Example # Enter stringword=input()# Check for palindrome strings using list slicingifstr(word)==str(word)[::-1]:print("Palindrome")else:print("Not Palindrome") The program begins by prompting the user to input a string using theinput()function...
Step 1: We have to find out if the given string is a palindrome or not. So to do this task we will create a function called isPalindrome and in this function, we will pass a parameter of string as str. So for this str, we will check the palindrome condition. Step 2: After the...
Learn how to check if a given number is a perfect number in Java with this simple guide and example code.
Check Palindrome String With theString.Substring()Method inC# A string is considered palindrome if it is read the same forward and backward. Unfortunately, there is no built-in method to check whether a string is a palindrome or not in C#. But we can use theString.Substring()methodto split...
This is a modal window. No compatible source was found for this media. java.util.regex Pattern Matcher regular expression String "(.)*(\\d)(.)*" Pattern.compile() Matcher if the input string passes this regular expression pattern or not ...
No, the given stringisnotsymmetrical String5: khokho Yes, the given stringissymmetrical Related:How to Reverse a String in C++, Python, and JavaScript Python Program to Determine Whether a Given String Is Symmetrical or Not Below is the Python program to determine whether a given string is sy...