A palindromic number or numeral palindrome is a \"symmetrical\" number like 16461, that remains the same when its digits are reversed.
The term palindromic is derive
import Queue
import copy
def printPalindromesTillK(K):
q = Queue.Queue(K);
for i in range(0, 10):
q.put(str(i));
q.put(str(i) + str(i));
while(not q.empty()):
elem = q.get();
print elem;
for i in range(1, 10):
item = str(i) + elem + str(i);
if int(item) <= K:
q.put(item);
print printPalindromesTillK(10000);