keys in dictionary

?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Shi said:
I run the following code and got wrong message, but I still want to
make [1,2],[4,3] and [6,9] to be keys of the dictionary or change the
style a little bit. How to do that?

Make them tuples:
>>> p=[[1,2],[4,3],[6,9]]
>>> n=dict([(tuple(x),[]) for x in p])
>>> n
{(6, 9): [], (1, 2): [], (4, 3): []}

Regards,
Martin

P.S. Please don't cross-post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top