Knowee
Questions
Features
Study Tools

s=input("Enter the string\t") a=s.lower() if a[0:]==a[-1:]: print("Yes the string is palindrome") else: print("No the string is not palindrome") what's wrong

Question

s=input("Enter the string\t") a=s.lower() if a[0:]==a[-1:]: print("Yes the string is palindrome") else: print("No the string is not palindrome")

what's wrong

🧐 Not the exact question you are looking for?Go ask a question

Solution

The code you provided checks if a given string is a palindrome or not. However, there is a syntax error in the code. The correct code is as follows:

  1. Prompt the user to enter a string:
s = input("Enter the string: ")
  1. Convert the string to lowercase:
a = s.lower()
  1. Check if the first and last characters of the string are the same:
if a[0:] == a[-1:]:
  1. If the condition is true, print that the string is a palindrome:
    print("Yes, the string is a palindrome.")
  1. If the condition is false, print that the string is not a palindrome:
else:
    print("No, the string is not a palindrome.")

Make sure to fix the indentation in your code as well.

This problem has been solved

Similar Questions

word = input("enter a word") word = word.lower() turd = len(word) for i in range(0,turd,1): if word[i] == word[turd-i]: print("palindrome") else: print("no") palindrome()

Write a python program to check the given string is palindrome or not.

12. DS-PythonMCQUNSOLVEDWhich of the following code snippets correctly checks if a string is a palindrome? Answer( Please choose all correct answers )   CLEARword == word[::-1]word == reversed(word) word.sort() == word.sort(reverse=True)word == "".join(reversed(word))

Given an integer x, return true if x is a palindrome, and false otherwise. Example 1:Input: x = 121Output: trueExplanation: 121 reads as 121 from left to right and from right to left.Example 2:Input: x = -121Output: falseExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.Example 3:Input: x = 10Output: falseExplanation: Reads 01 from right to left. Therefore it is not a palindrome.

Write a programme to check whether given input is palindrome or notConstraintsABC != PalindromeMAM == Palindrome123 != Palindrome151 == Palindrome

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.