title: How to check if a string is a palindrome?
body: <p>I have a code to check whether a word is palindrome or not:</p>
  
  <pre><code>str = input("Enter the string")
  l = len(str)
  p = l-1
  index = 0
  while index &lt; p:
      if str[index] == str[p]:
          index = index + 1
          p = p-1
          print("String is a palindrome")
          break
      else:
          print("string is not a palindrome")
  </code></pre>
  
  <p>If a word is inputted, for example : rotor , I want the program to check whether this word is palindrome and give output as "The given word is a palindrome".</p>
  
  <p>But I'm facing problem that, the program checks first r and r and prints "The given word is a palindrome" and then checks o and o and prints "The given word is a palindrome". It prints the result as many times as it is checking the word.</p>
  
  <p>I want the result to be delivered only once. How to change the code? </p>