On Sat, 15 Jun 2013 11:55:34 +0100, Mark Lawrence wrote: > >>> sentence = "By the new group" > >>> words = sentence.split() > >>> words[words[0],words[-1]] > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: list indices must be integers, not tuple > > So why would the OP want a TypeError? Or has caffeine deprivation > affected your typing skills? :)
Yeah - that last: words[words[0],words[-1]] should probably have been: first_and_last = [words[0], words[-1]] or even: first_and_last = (words[0], words[-1]) Or even: first_and_last = [sentence.split()[i] for i in (0, -1)] middle = sentence.split()[1:-2] -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list