Answer to Question #240867 in Python for rrrrrrrrrrrrrr

Question #240867
  1. A palindrome is a word or a phrase that reads the same way backwards as forwards. Write a function that accepts a text string as input and determines whether or not the text string is a palindrome. Then write a program that uses this function. Prompt the user to enter a word or phrase and then inform the user whether or not the text entered qualifies as a palindrome. [Hint: there is a REVERSE method for a string. But to compare an string reversed this way, you need to convert to list: if list(str) == list(rev_str):]
1
Expert's answer
2021-09-22T23:48:39-0400
def isPalindrome(str1):
    return str1 == str1[::-1]
 
 
if __name__ == '__main__':
    
    str2 = input("Enter a string: ")
    res = isPalindrome(str2)
     
    if res:
        print(str2,"is Palindrome")
    else:
        print(str2,"is not Palindrome")

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS