63 831
Assignments Done
99,2%
Successfully Done
In August 2018

Answer to Question #40774 in Python for julia

Question #40774
Adapt the code so that the user is continually
asked to test whether no not some text that they enter is a palindrome until the user
enters the letter ’Q’ or ’q’.
The output should look something like this:
Enter some text to test to see if it is a palindrome . Enter ’Q’ to quit :
madam Is " madam " a palindrome ? True
Enter some text to test to see if it is a palindrome . Enter ’Q’ to quit :
David
Is " David " a palindrome ? False
Enter some text to test to see if it is a palindrome . Enter ’Q’ to quit :
Rise to vote , Sir
Is " Rise to vote , Sir " a palindrome ? True
Enter some text to test to see if it is a palindrome . Enter ’Q’ to quit :
Q
Process finished with exit code 0

__author__ = ’ davidbrowning ’
‘‘‘ SN 12345678 ’’’
def reverse ( text ):
return text [:: -1]
def isPalindrome ():
text = input (’Enter possible palindrome : \n’)
print (’Is ’,text ,’a palindrome ?’,text == reverse ( text ))

’’’ Checking to see if text is a palindrome should ignore punctuation ,
white space and case . What needs to be
Expert's answer
__author__ = ' davidbrowning '
''' SN 12345678 '''

import sys

def reverse ( text ):
return text [:: -1]

def isPalindrome ():
text = input ('Enter possible palindrome : \n')
text = text.upper().replace(' ', '')
if text == 'Q': sys.exit()
print ('Is ', text, 'a palindrome ?', text == reverse(text))

while True:
isPalindrome()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions