Skip to content

Instantly share code, notes, and snippets.

@PushkraJ99
Last active April 28, 2022 03:14
Show Gist options
  • Select an option

  • Save PushkraJ99/bab8293fd1d02676467e72d7622c491b to your computer and use it in GitHub Desktop.

Select an option

Save PushkraJ99/bab8293fd1d02676467e72d7622c491b to your computer and use it in GitHub Desktop.
Palindrome.py
# 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