[Tutor] Difference between for i in range(len(object)) andfor iin object

Jacob S. keridee at jayco.net
Sat Dec 18 22:35:20 CET 2004


> Thing is, for people like me, you generally either don't know that a
> question is a dumb one until someone tells you the answer, (the 'of
> course' <smack forehead> moment), or until 5 minutes after you emailed
> your query, you find the answer you were looking for...

Amen! My life's story!

Also, to Kumar.

This is what you want.

test_cor = []
for line in cor:
    test_cor.append(line.split('\t',1)[1])  ## This only works if there are
only 3 columns

Or, even simpler:

test_cor = [line.split('\t',1)[1] for line in cor]

HTH,
Jacob



More information about the Tutor mailing list