Exercise: Palindrome
Leer en Español | Solve Online
Background/Motivation
A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization in some cases). In computer science, determining if a string is a palindrome is a classic exercise in string manipulation and pointer logic.
The Task
Implement a function palindrome(text: str) -> bool that checks whether a given string is a palindrome. For this exercise, we will consider the exact string, meaning case and characters matter.
Specifications
- Function Name:
palindrome - Arguments:
text(str) - Return Type:
bool - Expected Output:
Trueif the string is a palindrome,Falseotherwise.
Constraints
- The input string will contain only ASCII characters.
- $0 \le \text{len(text)} \le 1000$
Example
Instructions
- Open
exercises/palindrome/solution.py. - Implement the
palindromefunction. - Change
SUBMIT = FalsetoSUBMIT = Trueat the top of the file when you are ready to be graded. - Run
python solution.pylocally to verify your solution with the built-in self-tests.