[Tutor] Creating a dictionary
Válas Péter
sulinet at postafiok.hu
Fri May 27 16:36:29 CEST 2011
2011. május 27. 16:31 írta, <spawgi at gmail.com>:
> I think the way - d = dict({'one': 1, 'two': 2}) can be used to created
> dictionary using list comprehension.
> e.g.
> >>> d = dict((i,i**2) for i in range(10))
>
> I think this is not the same syntax, there are no braces in. dict({'one':
1, 'two': 2}) rather seems to me as a converting function that creates a
dictionary from a dictionary.
Thank you anyway!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110527/b3013549/attachment.html>
More information about the Tutor
mailing list