Created
March 29, 2020 18:20
-
-
Save Deep18-03/e8528419c6099bb536728d699d129cdc to your computer and use it in GitHub Desktop.
palindrome program
This file contains 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
''' | |
1.word[::-1] inverts the input | |
2.word.find(s) returns the index of s inside word or -1 if word doesnot contain s.since we use the entire input, | |
we get either 0 or-1 | |
3.since bool(0)=False and bool(1)=True we simply add 1 to the result brfore we convert it ro the bool value ''' | |
word=input("enter the basestring") | |
p=bool(word.find(word[::-1])+1) | |
print(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment