Re: String manipulation in python..NEED HELP!!!!

2012-12-11 Thread duncan smith
On 10/12/12 22:38, qbai...@ihets.org wrote: I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i

Re: String manipulation in python..NEED HELP!!!!

2012-12-11 Thread Terry Reedy
On 12/10/2012 5:59 PM, John Gordon wrote: def encode(plain): '''Return a substituted version of the plain text.''' encoded = '' for ch in plain: encoded += key[alpha.index(ch)] return encoded The turns an O(n) problem into a slow O(n*n) solution. Much better to build a

Re: String manipulation in python..NEED HELP!!!!

2012-12-11 Thread Ross Ridge
John Gordon wrote: def encode(plain): '''Return a substituted version of the plain text.''' encoded = '' for ch in plain: encoded += key[alpha.index(ch)] return encoded Terry Reedy tjre...@udel.edu wrote: The turns an O(n) problem into a slow O(n*n) solution. Much

Re: String manipulation in python..NEED HELP!!!!

2012-12-11 Thread Tim Delaney
On 12 December 2012 07:52, Ross Ridge rri...@csclub.uwaterloo.ca wrote: John Gordon wrote: def encode(plain): '''Return a substituted version of the plain text.''' encoded = '' for ch in plain: encoded += key[alpha.index(ch)] return encoded Terry Reedy

Re: String manipulation in python..NEED HELP!!!!

2012-12-11 Thread Peter Pearson
On Tue, 11 Dec 2012 16:39:27 +, duncan smith wrote: [snip] alpha = ABCDEFGHIJKLMNOPQRSTUVWXYZ key = XPMGTDHLYONZBWEARKJUFSCIQV mapping = {} for i, ch in enumerate(alpha): mapping[ch] = key[i] mapping = dict(zip(alpha, key)) -- To email me, substitute nowhere-spamcop,

String manipulation in python..NEED HELP!!!!

2012-12-10 Thread qbailey
I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i have the basic code but need help with how to

Re: String manipulation in python..NEED HELP!!!!

2012-12-10 Thread John Gordon
In d6779e35-32b8-417a-abf9-72454573b...@googlegroups.com qbai...@ihets.org writes: crypto.py Implements a simple substitution cypher alpha = ABCDEFGHIJKLMNOPQRSTUVWXYZ key = XPMGTDHLYONZBWEARKJUFSCIQV def main(): keepGoing = True while keepGoing: response = menu()

Re: String manipulation in python..NEED HELP!!!!

2012-12-10 Thread Vlastimil Brom
2012/12/10 qbai...@ihets.org: I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i have the

Re: String manipulation in python..NEED HELP!!!!

2012-12-10 Thread Chris Angelico
On Tue, Dec 11, 2012 at 9:38 AM, qbai...@ihets.org wrote: I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the