Palindromic game in Python This is just a little palindromic game that searches all palindromic numbers in ur random generated list. Feel free to give me some advice.

import random

numbers = []
total = []
dice = random.randint(1000, 50000)


while len(numbers) &lt; dice:
        x = random.randint(100000, 1000000)
        numbers.append(x)


def palindrome(n):
    check_palin = []
    for i in n[::-1]:
        i = str(i)
        check_palin.append(i)
        for k in check_palin:
            k = k[::-1]
            check_palin.clear()
            if k == i:
                total.append(k)
    print(total)
    numbers.clear()


palindrome(numbers)

length = len(total)


if length &gt; 58:
    print("\nHolly Shit!!! You broke my record!!! with %d." % (length))

elif length == 58:
    print("\nWow, Nice!!! %d is my highest Palindromic number (too).\nThat's a draw" % (length))
Instead of saving len(total), just use:

if len(total) &gt; 58:
     print("\nHolly Shit!!! You broke my record!!! with %d." % (length))

elif len(total) == 58:
    print("\nWow, Nice!!! 58 is my highest Palindromic number (too).\nThat's a draw") 
    # Since you hardcoded your -highscore-, there's no need to use a variable to print the highscore.


Use whitespace more efficiently, especially in your palindrome() function.
Instead of converting n to str() in your palindrome() function, use numbers.append(str(x)). This way you can reuse palindrome() and have it take n as a string by default (or use an assertion / try: except: statement).

Rewritten:

from random import randint

numbers = []
palindromes = []
dice = randint(1000, 50000)

while len(numbers) &lt; dice:
    x = randint(100000, 1000000)
    numbers.append(str(x))


def palindrome(n):
    for i in n[::-1]:
        if i == i[::-1]:
            palindromes.append(i)
    return palindromes


palindromes = palindrome(numbers)
print(palindromes) # To check this works

if len(palindromes) &gt; 58:
    print("\nHoly shit! You broke my record with %d!\n" % (length))

elif len(palindromes) == 58:
    print("\nWow, nice! 58 is my highest palindromic number too!\n")