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()
Question
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()
Solution
It seems like you're trying to write a Python program to check if a word is a palindrome. A palindrome is a word that reads the same backwards as forwards. However, your code has a few errors. Here's a corrected version:
def palindrome():
word = input("Enter a word: ")
word = word.lower()
reversed_word = word[::-1] # This will reverse the string
if word == reversed_word:
print("The word is a palindrome")
else:
print("The word is not a palindrome")
palindrome()
In this corrected version, we define a function palindrome(). Inside this function, we ask the user to input a word. We convert this word to lowercase to ensure the palindrome check is case-insensitive. We then reverse the word using Python's slice notation [::-1]. If the reversed word is the same as the original word, we print that the word is a palindrome. Otherwise, we print that the word is not a palindrome. Finally, we call the function palindrome() to execute the code.
Similar Questions
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
In the first line of input, accept a sequence of space-separated words. In the second line of input, accept a single word. If this word is not present in the sequence, print NO. If this word is present in the sequence, then print YES and in the next line of the output, print the number of times the word appears in the sequence.words = input().split('')test = input()if test not in words: Print('No')else: Print('YES') count = 0 for word in words: if test == word: count -= 1 Print(count)Sample Test CasesDownload All Test Case 1InputExpected OutputActual Outputa good collection of wordstheNOTest Case 2InputExpected OutputActual Outputno sentence can begin with because because because is a conjunctionbecauseYES3
Write a python program to check the given string is palindrome or not.
Test time left: 33:41Write the codeTake the input as string from the user, If any permutation of the word is palindrome then return "True" or else return "False"For example : "carrace" should return "True", since it can be rearranged to form "racecar", which is a palindrome."daily" should return "False", since there's no rearrangement that can form a palindrome.Sample Test CasesTest Case 1:Expected Output:Enter·the·word:·dyyadaTrueTest Case 2:Expected Output:Enter·the·word:·carraceTrueTest Case 3:Expected Output:Enter·the·word:·daisyFalse
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))
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.