[Tutor] remove blank list items
Luke Paireepinart
rabidpoobear at gmail.com
Sat Sep 15 06:14:19 CEST 2007
Terry Carroll wrote:
> On Fri, 14 Sep 2007, Michael Langford wrote:
>
>
>> What you want is a set, not a list. Lucky for you, a python dict uses a
>> set for its keys, so cheat and use that.
>>
>
> Is that true?
>
>
>>>> d={1:"a", 2:"b"}
>>>> k=d.keys()
>>>> type(k)
>>>>
> <type 'list'>
>
He worded it incorrectly since there is actually a 'set' type, but what
he meant was that there wouldn't be multiples of each key that you add,
so you would effectively eliminate multiples and thus have a set when
you get a list of dict keys.
-Luke
More information about the Tutor
mailing list