Competitive Programming Question in Python |
In this article, we are going to write a python program to check if the given number is palindrome or not.
If you are looking for a Python Tutorial then it's here
def palindrome(word):
if word == '':
return True
else:
return word == word[::-1]
def main():
x = input('Enter the string: ')
if palindrome(x):
print('String is a palindome')
else:
print('String is not a palindrome')
main()
Now check for the palindrome strings
Enter the string:
String is a palindome
Enter the string: 131
String is a palindome
Enter the string: gsgssgs
String is not a palindrome
Comments
Post a Comment