Changing numbers into characters using dictionaries

Colin Fox cfox at cfconsulting.ca
Fri Jan 27 01:33:07 CET 2006


On Thu, 26 Jan 2006 20:35:26 +0000, 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 = '@7704 at 7002@7075 at 7704' // 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"}

Well, your num[3] is going to return '6', not '4', so your key lookup is
going to fail right there. Same with num[5], which is 4, not 5.

-- 
Colin Fox
President
CF Consulting Inc.




More information about the Python-list mailing list