Answers for "convert alphanumeric to numeric python"

0

convert alphanumeric to numeric python

chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" #these are the digits you will use for conversion back and forth
charsLen = len(chars)

def numberToStr(num):
  s = ""
  while num:
    s = chars[num % charsLen] + s
    num //= charsLen

  return(s)

def strToNumber(numStr):
  num = 0
  for i, c in enumerate(reversed(numStr)):
    num += chars.index(c) * (charsLen ** i)

  return(num)
Posted by: Guest on March-14-2020

Code answers related to "convert alphanumeric to numeric python"

Python Answers by Framework

Browse Popular Code Answers by Language