else
This commit is contained in:
parent
87f4c44976
commit
fa71076e40
1 changed files with 3 additions and 0 deletions
|
@ -11,6 +11,9 @@ TERMINALWIDTH = shutil.get_terminal_size().columns
|
||||||
|
|
||||||
def basex(number, base, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
|
def basex(number, base, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
|
||||||
"""Converts an integer to a different base string."""
|
"""Converts an integer to a different base string."""
|
||||||
|
if base > len(alphabet):
|
||||||
|
raise Exception('alphabet "%s" does not support base %d' % (
|
||||||
|
alphabet, base))
|
||||||
alphabet = alphabet[:base]
|
alphabet = alphabet[:base]
|
||||||
if not isinstance(number, (int, str)):
|
if not isinstance(number, (int, str)):
|
||||||
raise TypeError('number must be an integer')
|
raise TypeError('number must be an integer')
|
||||||
|
|
Loading…
Reference in a new issue