Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34637
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: String manipulation in python..NEED HELP!!!! |
| Date | 2012-12-11 14:30 -0500 |
| References | <d6779e35-32b8-417a-abf9-72454573bf56@googlegroups.com> <ka5pfp$ge0$1@reader1.panix.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.737.1355254259.29569.python-list@python.org> (permalink) |
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 list of chars and then join them. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
String manipulation in python..NEED HELP!!!! qbailey@ihets.org - 2012-12-10 14:38 -0800
Re: String manipulation in python..NEED HELP!!!! John Gordon <gordon@panix.com> - 2012-12-10 22:59 +0000
Re: String manipulation in python..NEED HELP!!!! Terry Reedy <tjreedy@udel.edu> - 2012-12-11 14:30 -0500
Re: String manipulation in python..NEED HELP!!!! Ross Ridge <rridge@csclub.uwaterloo.ca> - 2012-12-11 15:52 -0500
Re: String manipulation in python..NEED HELP!!!! Tim Delaney <timothy.c.delaney@gmail.com> - 2012-12-12 08:34 +1100
Re: String manipulation in python..NEED HELP!!!! Vlastimil Brom <vlastimil.brom@gmail.com> - 2012-12-11 00:25 +0100
Re: String manipulation in python..NEED HELP!!!! Chris Angelico <rosuav@gmail.com> - 2012-12-11 10:36 +1100
Re: String manipulation in python..NEED HELP!!!! duncan smith <buzzard@invalid.invalid> - 2012-12-11 16:39 +0000
Re: String manipulation in python..NEED HELP!!!! Peter Pearson <ppearson@nowhere.invalid> - 2012-12-11 22:21 +0000
csiph-web