Question

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


0 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1
s = input()
low = 0
high = len(s)-1
result = True
while(low
            
Add a comment
Know the answer?
Add Answer to:
A palindrome is a word or a phrase that is the same when read both forward and backward.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT