On Nov 5, 10:53 pm, Davy <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> We know that list cannot be used as key of dictionary. So, how to work
> around it?
>
> For example, there is random list like l=[1,323,54,67].
>
> Any suggestions are welcome!
>
> Best regards,
> Davy

Use a tuple instead.

>>> d = {}
>>> d[tuple([1,2,3,4])] = 'hello world'
>>> d
{(1, 2, 3, 4): 'hello world'}
>>> d[1,2,3,4]
'hello world'

Matt

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

Reply via email to