Answer to Question #303426 in Python for junior

Question #303426

Write a function called Reverse that takes in a string value and returns the string with the characters in reverse. If the string reads the same forwards as it does backwards the function should output “[word] is a palindrome!”.


Ex:

Reverse(“apple”)

outputs elppa

Reverse(“racecar”)

outputs racescar is a palindrome!


Hint: Make sure you take in your input and then make it lower case using the .lower() method.




1
Expert's answer
2022-02-27T04:29:23-0500
string = input().lower()
x = ""
for i in string:
    x = i + x
if string == x:
    print(x, "is a palindrome!")
else:
    print(x)

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