Re: how to add new tuple as key in dictionary?

2017-07-05 Thread John Gordon
In <344c23f8-f440-4c23-a5e6-9f93b0145...@googlegroups.com> Ho Yeung Lee writes: > I find that list can not be key in dictionary > then find tuple can be as key > but when I add new tuple as key , got error in python 2.7 > groupkey = {(0,0): []} > groupkey[tuple([0,3])] =

Re: how to add new tuple as key in dictionary?

2017-06-30 Thread Stephen Tucker
Hello there, Ho Yeung Lee, The use of groupkey[tuple([0,3])] to the right of the = is attempting to access an entry in your dictionary that you have not already created. That is why you are getting the error message. You need to create an entry whose key is tuple([0,3]) before you can access it.

Re: how to add new tuple as key in dictionary?

2017-06-30 Thread Peter Otten
Ho Yeung Lee wrote: > I find that list can not be key in dictionary > then find tuple can be as key > > but when I add new tuple as key , got error in python 2.7 > > groupkey = {(0,0): []} > groupkey[tuple([0,3])] = groupkey[tuple([0,3])] + [[0,1]] First try to understand that you get the same

how to add new tuple as key in dictionary?

2017-06-30 Thread Ho Yeung Lee
I find that list can not be key in dictionary then find tuple can be as key but when I add new tuple as key , got error in python 2.7 groupkey = {(0,0): []} groupkey[tuple([0,3])] = groupkey[tuple([0,3])] + [[0,1]] -- https://mail.python.org/mailman/listinfo/python-list