Exercise 10: Palindrome Checker, Index-Based — Possible Solution ==================================================================== def is_palindrome(word): for i in range(len(word)): opposite_index = len(word) - 1 - i if word[i] != word[opposite_index]: return False return True print(is_palindrome("level")) print(is_palindrome("python")) Output: True False WHY THIS WORKS AS AN ANSWER ------------------------------ For every index i counting up from the front, len(word) - 1 - i gives the matching index counting down from the back — when i is 0, opposite_index is the very last character; when i is 1, it's the second-to-last; and so on, until the two meet in the middle. This is exactly the kind of "two positions moving toward each other" pattern that needs real index access, since for ch in word: only ever hands you one character at a time with no way to reach back to its mirror position on the other end. The function returns False the instant it finds a single mismatch, without needing to check the rest of the word — for "python", p vs n already fails on the very first comparison. If the loop finishes every single comparison without ever hitting that early return, the function falls through to return True, since every character genuinely matched its mirror. Technically the loop checks each pair twice (once from each side), which is harmless but not the most efficient version — a working first solution, not the fastest one.