Created
October 15, 2015 18:27
-
-
Save javi830810/5d6bf6bb0bbb5a9ba403 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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