Peng Yu wrote:
I'm wondering if there is something similar to list comprehension for
dict (please see the example code below).

Do you mean something like this:

>>> {i:i+1 for i in [1,2,3,4]}
{1: 2, 2: 3, 3: 4, 4: 5}

This works in python3, but not in python2

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

Reply via email to