Last active
April 28, 2022 03:14
-
-
Save PushkraJ99/bab8293fd1d02676467e72d7622c491b to your computer and use it in GitHub Desktop.
Palindrome.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Program to check if a string is palindrome or not | |
| string = input("Input the String:") | |
| # make it suitable for caseless comparison | |
| string = string.casefold() | |
| # reverse the string | |
| rev_str = reversed(string) | |
| # check if the string is equal to its reverse | |
| if list(string) == list(rev_str): | |
| print("The string is a Palindrome.") | |
| else: | |
| print("The string is not a Palindrome.") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment