Question

In: Other

A palindrome is a word or a phrase that is the same when read both forward and backward.

6.7 LAB: Palindrome

A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.

Ex: If the input is:

bob

the output is:

bob is a palindrome

Ex: If the input is:

bobby

the output is:

bobby is not a palindrome

Hint: Start by removing spaces. Then check if a string is equivalent to it's reverse.

This is my code:

s = input()
low = 0
high = len(s)-1
flag = False
while(low<high):
if(s[low]!=s[high]):
flag = True
break
low+=1
high-=1
if(flag):
print(s,"is a palindrome")
else:
print(s, "is not a palindrome")

This is what i needs to be solved:

1: Compare output ^ Output differs. See highlights below. Special character legend Input bob Your output bob is not a palindr3: Compare output Input never odd or even Your output never odd or even is a palindrome 4: Compare output Output differs. See


Solutions

Expert Solution

s = input()
low = 0
high = len(s)-1
result = True
while(low
                    

Related Solutions

JAVA. A palindrome is a word or a phrase that is the same when read both forward and backward.
java please. A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.Ex: If the input is:bobthe output is:bob is a palindromeEx: If the input is:bobbythe output is:bobby is not a palindromeHint: Start by removing spaces. Then check if a string is equivalent to it's reverse.Hint: Start by just handling single-word...
A palindrome is a word or phrase, which reads the same backward or forward. Write a...
A palindrome is a word or phrase, which reads the same backward or forward. Write a program that prompts the user for a string of characters terminated by a period and determines whether the string (without the period) is a palindrome. IMP: Assume that the input contains only letters and blanks. Assume also that the input is at most 30 characters long. Use an array of characters of size 30 to store the input! Disregard blanks when deciding if the...
C++: A palindrome is a string that is the same backward as it is forward. For...
C++: A palindrome is a string that is the same backward as it is forward. For example, “tot” and “otto” are rather short palindromes. Write a program that lets a user enter a string and that passes to a bool function a reference to the string. The function should return true if the string is a palindrome and false otherwise. When you do the judgment, capitalization, spaces, and punctuation should be neglected, that is, “Madam, I’m Adam” should test as...
python question A word is a palindrome if it the same read forwards and backwards. We...
python question A word is a palindrome if it the same read forwards and backwards. We will call a word a fuzzy palindrome if it is the same read forwards and backwards, except for possible differences in case. For example, both 'tattarrattat' and 'TaTtArRAttat' are fuzzy palindromes. Define a function is_fuzzy_palindrome that returns True if and only if its argument is a fuzzy palindrome. This method may be useful: S.lower() -> str : Return a copy of the string S...
Write out the steps for one model selection technique (backward/forward-elimination with the R-squared, backward/forward-elimination with the...
Write out the steps for one model selection technique (backward/forward-elimination with the R-squared, backward/forward-elimination with the p-value approach, etc.).
what is the difference between a backward and a forward linkage with respect to railroads?
what is the difference between a backward and a forward linkage with respect to railroads?
Define Vertical Integration Strategies (Forward, Backward & Horizontal Integration)
Define Vertical Integration Strategies (Forward, Backward & Horizontal Integration)
A palindromic number reads the same both ways (left-to-right and right-to-left). The largest palindrome made from...
A palindromic number reads the same both ways (left-to-right and right-to-left). The largest palindrome made from the product of two 2-digit numbers is 9,009 = 91 × 99. The largest palindrome made from the product of two 3-digit numbers is 906,609 = 913 × 993. The largest palindrome made from the product of two 4-digit numbers is 99,000,099 = 9,901 × 9,999. 1. Write a function IN JAVASCRIPT to find the largest palindrome made from the product of two 7-digit...
In C++: This is the problem: [(1)] A palindrome is a string that reads the same...
In C++: This is the problem: [(1)] A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the string is read from standard input one character at a time. The algorithm should output true or false as appropriate [(2)] Let Q...
Highlight the performance of the forward and backward lunge as well as the step up. What...
Highlight the performance of the forward and backward lunge as well as the step up. What are the prime movers, how are lunges similar and different from one another. Finally, what types of athletes could benefit from using these exercises and why?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT