Alphabetizing?
mackstann
mack at incise.org
Sun Aug 24 17:32:58 EDT 2003
On Sat, Aug 23, 2003 at 01:27:52PM -0400, tjland at iserv.net wrote:
> Ok, im trying to creat a small simple program that alphabetizes user
> inputed words. I thought why not just create a def that splits all the
> words down into char's then take the first char and crosscheck it with all
> lowercase letters. Then find its position and return the results to the
> user in order or 1-26! But this takes a long time and the code gets
> confusing. Any suggestion? Thanx in advance!
Put them in a list and sort them?
>>> text = "hello how are you? i'm just fine, blah blah."
>>> l = text.split()
>>> l
['hello', 'how', 'are', 'you?', "i'm", 'just', 'fine,', 'blah', 'blah.']
>>> l.sort()
>>> l
['are', 'blah', 'blah.', 'fine,', 'hello', 'how', "i'm", 'just', 'you?']
--
m a c k s t a n n mack @ incise.org http://incise.org
Excellent time to become a missing person.
More information about the Python-list
mailing list