On 18 December 2011 19:41, HoneyMonster <someone@someplace.invalid> wrote: > Hi, > > I'm just starting to learn Python, so please bear with me. I have in my > program an object (recs) which is a list of tuples (returned as such by a > database query). > > My question is doubtless a very easy one to answer: Say I want the ninth > element in the twentieth tuple put into variable PID, I can do this, > bearing in mind that numbering starts at zero: > > tup = recs[19] > PID = tup[8] > > But there must be an easier way; i.e. to do it in one go without the > extra variable. How do I achieve that please?
Well, you were almost there: pid = recs[19][8] Note: all caps is usually reserved for constants in Python. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list