CJCoding With Joseph
15free / daySign inCreate account

Palindrome By Shrinking

Complete is_palindrome(s: str) -> bool so it returns True when the text reads the same backwards and False otherwise, by recursion. The base case is written: a string of length 0 or 1 is a palindrome. Add the recursive case: if the first and last characters differ, return False; otherwise return whether the middle, the slice s[1:-1], is itself a palindrome. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one line of text, no prompt, which the tests read and pass to your function before printing the value it returns.

Expected Output:

True

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
RecursionSlicing
📥 Auto-Input:
racecar\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.