def double_base_palindromes(max_n): """ Return a list of all decimal-binary palindromes up to max_n.""" palindromes = [] for n in range(1, max_n + 1, 2): # binary palindromes must be odd if common.is_str_palindrome(str(n)) and common.is_str_palindrome(bin(n)[2:]): palindromes.append(n) return palindromes
def is_num_palindrome(n): if n < 10: return True else: return common.is_str_palindrome(str(n))