Danny wrote: > Hello again, > > I am now trying to make something to change some "encrypted" text into > some plain text, here is the code I have so far: > > text = '@[EMAIL PROTECTED]@[EMAIL PROTECTED]' // some text > num = '213654' // Number > s1 = '700' > s2 = '770' > s4 = '707' // it adds these later on. > t = text.split('@') // splits the digits/blocks apart from each other > a = {s2+num[3]:"l", s1+num[0]:"a", s4+num[5]:"w"} > > something = 1 > while True: > var = str(a[t[something]]) > print var, > // I want it to change "@[EMAIL PROTECTED]@[EMAIL PROTECTED]" into "lawl" > > I get the error: > Traceback (most recent call last): > File "C:/Documents and Settings/Danny/My > Documents/python/changetext.py", line 9, in ? > var = str(a[t[something]]) > KeyError: '7704' > > I've explained what is needed to happen in the comments. Also, if any of > you can think of a better way to do this can you possibly tell me this? > Thanks.
text = '@[EMAIL PROTECTED]@[EMAIL PROTECTED]' a={'7704':'l','7002':'a','7075':'w'} u=[] for c in text.split('@')[1:]: u.append(a[c]) print ''.join(u) Larry Bates -- http://mail.python.org/mailman/listinfo/python-list