Longest Palindromic Substring
First things first, I'll highlight areas I felt you should change.


Make a function.
Don't litter the program with blackbox debugging 'comments'.
Don't use enumerate if you don't need both index and letter.
It's easier to read one slice rather than two.
You could change your while loop to a for loop, this reduces the amount of statements in the if.


Most of these are pretty simple, and are mostly due to your debugging.
I'll elaborate on 5 as it's the only one that I should need to explain.

If we rearrange both \$\text{index} - \text{stretch} &gt;= 0\$ and \$\text{index} + \text{stretch} &lt; \text{length}\$ to get stretch.
This gets \$\text{index} &gt;= \text{stretch}\$ and \$\text{length} - \text{index} &gt; \text{stretch}\$.
As we know the input are integers we can get both to use the same sign, &gt;.
With \$\text{index} + 1 &gt; \text{stretch}\$.
If we merge them both together we get: \$\text{min}(\text{index} + 1, \text{length} - \text{index}) &gt; \text{stretch}\$.

This basically means you can use the following range:

for stretch in range(1, min(index + 1, length - index)):


You should note, it won't go above the largest possible stretch and so you should only do stretch -= 1 if you break from the loop.

All of this together should get you:

def get_longest_palendrome(string):
    string = string.replace('', '^')
    longest = 0
    position = 0
    length = len(string)
    for index in range(length):
        stretch = 0
        for stretch in range(1, min(index + 1, length - index)):
            text = string[index - stretch:index + stretch + 1]
            if text != text[::-1]:
                stretch -= 1
                break
        if stretch &gt; longest:
            longest = stretch
            position = index
    position -= longest
    return string[position:position + (2*longest + 1)].replace('^', '')




The second I looked at string = string.replace('', '^') I thought this can't be an \$O(n^3)\$ algorithm.
I don't know the actual complexity, but you instantly change the length of string to \$2n + 1\$.
This means your function is more \$O((2n)^3)\$ or \$O(8n^3)\$

I know you normally ignore the coefficient but I think it's quite important to highlight the pitfall on doubling the size of the input.