On Mon, Dec 7, 2009 at 12:42 AM, Tsviki Hirsh <tsviki.hi...@gmail.com> wrote:
> Dear list,
> I'm trying to create a dictionary from set of keys and values using
> dict.fromkeys
> When I type:
>>>>dict.fromkeys('a',50)
> the output is:
> {'a': 50}
> This is fine, but when I try to set the same value to a different name key:
>>>>dict.fromkeys('at',50)
> the output now is:
> {'a': 50, 't': 50}
> This is obviously not what I wanted.
> What are the alternatives?

>>> dict.fromkeys(['at'],50)
{'at': 50}

Remember that strings are collections too (of individual characters).

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to