#!/usr/bin/python import os,sys,string f = open("words.txt"); list=f.readlines(); num = sys.argv[1] g=[] for i in list: g.append(string.strip(i)) theBase = len(g) if sys.argv[0] == "./wordnum": theNum = string.atoi(num); h = [] while theNum > len(g)-1: inum = ((theNum) % len(g)) h.insert(0, inum) theNum = theNum / len(g) h.insert(0, theNum); str = "" for i in h: str = str+g[i] print str else: index0 = 0 h = [] while index0 < len(num): index1 = index0+1 while index1 < (len(num)+1): try: ind = g.index(num[index0:index1]) index0=index1 h.insert(0, ind) except ValueError: index1 = index1+1 theNum = 0 for i in range(0,len(h)): theNum = theNum + h[i] * pow(theBase, i) print(theNum)