In this code challenge we check if a string entered by the user is a palindrome.
Write a program that checks if a string entered by the user is a palindrome. A palindrome is a word that reads the same forwards as backwards like “racecar" or "hannah".
A palindrome program is one of the easiest programs to write!
In some programming languages reversing text is done in different ways, so in the code below we simply reverse it using the REVERSE
keywords.
First, we get the user input, and then reverse the text and store the result in a new variable reversed_text
.
text = INPUT
reversed_text = REVERSE text
After that, we check if the text entered is the same as the reversed text.
IF text = reversed_text THEN
OUTPUT "The text you entered is a palindrome!"
ELSE
OTUPUT "The text you entered is NOT a palindrome!"