Hi dkrumm, On 3 Sep., 09:33, dkrumm <dkr...@uga.edu> wrote: > Is there a data structure in Python that would allow me to do the > following: > > I have a list of positive integer pairs, say [[1,2], [1,3], [2,5]]. > For each pair [i,j] in my list I need to store in memory a number > c[i,j]
Indeed, it is just a Python question. I suggest you read something about Python dictionaries. You could not index a Python dictionary by *lists*, because lists are mutable, and hell breaks if the keys of a dictionary are modified after creation. But they can be indexed by tuples. Hence, you can do: sage: L = [(1,2),(3,4),(5,6)] sage: D = dict(zip(L,range(3))) sage: D {(1, 2): 0, (5, 6): 2, (3, 4): 1} sage: D[3,4] 1 Best regards, Simon -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org