This solution avoids going through all of the combinations from 0000 to your starting input:
start = '22Ef'
end = 'FFFF'
characterset = '0123456789abcdefABCDEF'
base = len(characterset)
baseNnumber = [] # little endian list of integers each representing a digit
# find base N representation of start
exponent = 0
startval = 0
for i in start[::-1]:
digit = characterset.index(i)
baseNnumber.append(digit)
startval += digit * base**exponent
exponent += 1
baseNnumber.extend([0]*(len(end)-len(start)))
# find representation of end
exponent = 0
endval = 0
for i in end[::-1]:
digit = characterset.index(i)
endval += digit * base**exponent
exponent += 1
# number of times to print
increments = endval - startval + 1
for i in range(increments):
index = 0
outstr = ''
# remove leading zeros
notzero = False
for i in baseNnumber[::-1]:
notzero = notzero | (i != 0)
# add new character to string
outstr += characterset[i] * notzero
# the actual printing
print(outstr)
# increment baseNnumber by 1
while True:
baseNnumber[index] += 1
if baseNnumber[index] == base:
baseNnumber[index] = 0
index += 1
else:
break
If you want the leading zeros included you may want to replace lines 34-38 with this as notzero is meant to remove them:
for i in baseNnumber[::-1]:
outstr += characterset[i]
Or if you are certain the start and end inputs are the same simply delete line 17 and make the replacement above as it's meant to solve the issue of start and end inputs being different lengths.