```
# -*- coding: cp1252 -*-
from random import randint
symbols = '0123456789abcdefghijklmnopqrstuvwxyzÃ¥Ã¤Ã¶'
symbol_values = dict(reversed(v) for v in enumerate(symbols))
def int_to_base(number, base):
if base > len(symbols) or base < 2:
raise ValueError('Invalid base %i' % base)
s = ''
if number < 0:
number, neg = -number, True
else:
neg = False
while number:
number, this = divmod(number, base)
s = symbols[this] + s
return (neg * '-' ) + s
def value_in_base(string, base):
minus = string.lstrip().startswith('-')
v = sum(symbol_values[sym] * base ** power
for power, sym in enumerate(reversed(string.strip(' -'))))
return -v if minus else v
num_check = 100
for count in range(num_check):
num, b = randint(-100000, 10000), randint(2,len(symbols))
print('Original %i' % num)
v = int_to_base(num, b)
print('%s base %i' % (v, b))
print(value_in_base(v, b))
if b < 37:
print('check: %s\n' % int(v, b))
assert int(v, b) == num
```

About the Author

*Edited 5 Years Ago by pyTony*: Spelling

*Edited 5 Years Ago by pyTony*: n/a

*Edited 5 Years Ago by pyTony*: n/a

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.