On 01/07/17 19:00, Lee Ho Yeung wrote: > My situation is a dictionary with tuple key > I think dictionary.values()[index] > Is correct
Unless your dictionary only has one element, this is almost certainly incorrect as dictionary items are not ordered: if this returns the right object, then it's by sheer luck. This could return something else on a different computer, or a different version of Python. In Python 3, you can't even do this. (By the way, you should be using Python 3!) Normally when you want to access a particular item of a dictionary you want to be indexing the dictionary itself: dictionary[key] -- Thomas > > > On Sun, 2 Jul 2017 at 12:48 AM, Pavol Lisy <pavol.l...@gmail.com> wrote: > >> On 7/1/17, Ho Yeung Lee <jobmatt...@gmail.com> wrote: >>> just want to compare tuples like index (0,1), (0,2), (1,2) without >>> duplicate >>> such as (2,0), (1,0) etc >>> >>> >>> On Saturday, July 1, 2017 at 7:00:17 PM UTC+8, Peter Otten wrote: >>>> Ho Yeung Lee wrote: >>>> >>>>> finally i searched dict.values()[index] solved this >>>> That doesn't look like a good solution to anything -- including "this", >>>> whatever it may be ;) >>>> >>>> If you make an effort to better explain your problem in plain english >>>> rather >>>> than with code examples you are likely tho get better answers. >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >>> >> [(i, j) for j in range(3) for i in range(j)] # is this good for you? >> -- https://mail.python.org/mailman/listinfo/python-list