Skip to content

Instantly share code, notes, and snippets.

@Deep18-03
Created March 29, 2020 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deep18-03/e8528419c6099bb536728d699d129cdc to your computer and use it in GitHub Desktop.
Save Deep18-03/e8528419c6099bb536728d699d129cdc to your computer and use it in GitHub Desktop.
palindrome program
'''
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