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.
string = input().lower()
x = ""
for i in string:
x = i + x
if string == x:
print(x, "is a palindrome!")
else:
print(x)
Comments
Leave a comment