In [2]:
from __future__ import print_function

In [19]:
def is_palindrome(x):
    return x == x[::-1]

In [20]:
def int_to_base(x, base):
    if x == 0:
        return ''
    div, mod = divmod(x, base)
    return int_to_base(div, base) + str(mod)

In [27]:
def which_bases(year):
    bases = range(2, 9)
    return [base for base in bases if is_palindrome(int_to_base(year, base))]

In [30]:
for year in range(2015, 2100):
    bases = which_bases(year)
    if bases:
        print(year, which_bases(year))


2015 [2]
2033 [5]
2035 [6]
2042 [3]
2043 [8]
2045 [4]
2047 [2]
2049 [2]
2050 [4]
2052 [8]
2056 [7]
2058 [5]
2064 [7]
2069 [3]
2071 [6]
2083 [5]
2096 [3]

In [ ]: