I have been working on something, and i'm stuck again...
I have to print out an infile list in columns, and then print it out again in alphabetical order(sort). I can't figure how to print in columns, nor can i soft it. Any help?

Each row is considered a line of text. In order to get a line of text you need a string, here's how i would do it, if i wanted to print to console the way you want it to look.

simple way:

>>> mylist = ['a', 'b', 'c', 'd']
>>> print ''.join(mylist) #ugly code
abcd

better way:

>>> import string
>>> print string.join(mylist, '')
abcd

Inefficient way, repetition of code:
If the function is already optimized twice in the above examples, why would you loop through it yourself

string = ''
for item in mylist:
    string = string + item + ''
print string

I'm importing a file of around 30 names, and then sorting it. I guess my hang up is not being able to see the list and still sorting it.
I'll get some of my code later for a better example.

This article has been dead for over six months. Start a new discussion instead.