Thank you, everyone, for resolving my question. At one point, while
trying to solve the problem, I typed

>>> y[1,3]
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: list indices must be integers

The error message gave me no clue as to what I was doing wrong (in my
mind, I was just writing out the elements of a range), and I thought
perhaps that my inclusion of a comma was the problem. Perhaps a more
explicit error message would have helped.

Another solution, I suppose, is to use a list comprehension. Store the
indices in a list x. For example, let x = [1,5,4]. Then

a,b,c = [y[i] for i in x]

Thanks

Thomas Philips

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to