Returning dictionary from a function

Jeff McNeil jeff at jmcneil.net
Thu May 14 18:00:16 EDT 2009


On May 14, 5:44 pm, kk <maymunbe... at gmail.com> wrote:
> Btw my main problem is that when I assign the function to 'b' variable
> I only get the last key from the dictionary. Sorry about that I forgot
> to mention the main issue.


You're creating a new dictionary with each iteration of your loop, use
d[k] = v syntax instead.



More information about the Python-list mailing list