Skip to content

Instantly share code, notes, and snippets.

@javi830810
Created October 15, 2015 18:27
Show Gist options
  • Select an option

  • Save javi830810/5d6bf6bb0bbb5a9ba403 to your computer and use it in GitHub Desktop.

Select an option

Save javi830810/5d6bf6bb0bbb5a9ba403 to your computer and use it in GitHub Desktop.
def is_int(c):
return ord(c) >= 48 and ord(c) <= 58
def get_int(c):
return ord(c) - 48
def int_to_parse(input):
result = 0
for x in xrange(0, len(input)):
character = input[x]
if not is_int(character):
raise Error("Invalid Input")
result += get_int(character) * (10**(len(input) - x - 1))
return result
print int_to_parse("123456")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment