Peter Otten wrote:
> Paul Rubin wrote:
>
>> Peter Otten <__pete...@web.de> writes:
>>> assert len(keydict) == len(mydict)
>>
>> assert set(keydict) == set(mydict)
>
> The weaker check is O(1), and, combined with the succeeding for loop,
> implies the above.
Sorry, I have to take that back:
Py
Paul Rubin wrote:
> Peter Otten <__pete...@web.de> writes:
>> assert len(keydict) == len(mydict)
>
> assert set(keydict) == set(mydict)
The weaker check is O(1), and, combined with the succeeding for loop,
implies the above.
--
https://mail.python.org/mailman/listinfo/python-list
Peter Otten <__pete...@web.de> writes:
> assert len(keydict) == len(mydict)
assert set(keydict) == set(mydict)
--
https://mail.python.org/mailman/listinfo/python-list
pozz wrote:
> I have a dictionary where the keys are numbers:
>
> mydict = { 1: 1000, 2: 1500, 3: 100 }
>
> I would like to convert keys from number to string representation:
>
> mydict = { "apples": 1000, "nuts": 1500, "tables": 100 }
>
> Of course, somewhere I have the association between ke
pozz writes:
> I have a dictionary where the keys are numbers: ...
Python 2.7.5:
>>> mydict = { 1: 1000, 2: 1500, 3: 100 }
>>> keydict = { 1: "apples", 2: "nuts", 3: "tables" }
>>> newdict = dict((keydict[k],v) for k,v in mydict.items())
>>> print newdict
{'tables': 100, 'nut
I have a dictionary where the keys are numbers:
mydict = { 1: 1000, 2: 1500, 3: 100 }
I would like to convert keys from number to string representation:
mydict = { "apples": 1000, "nuts": 1500, "tables": 100 }
Of course, somewhere I have the association between key-numbers and
key-strings, ma