Challenge 3: Check for a Palindrome
Given a string, check whether or not it is a palindrome.
We'll cover the following
Problem Statement
Write a function that takes a variable testVariable
, which contains a string, and checks whether or not it is a palindrome.
What is a “Palindrome”?
A Palindrome is a string that reads the same backward and forwards. For example , , etc. All strings with length are considered palindromes.
Remember, lower case letters are different from upper case letters, therefore, is not a palindrome.
Input
A variable testVariable
containing a string.
Output
True
if the input string is a palindrome. False
if the string is not a palindrome.
Sample Input
"madam"
Sample Output
True
Try it Yourself
Try this challenge yourself before examining the solution. Good luck!
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.