[Tutor] Remove a dictionary entry

Joel Goldstick joel.goldstick at gmail.com
Fri Sep 17 19:34:09 CEST 2010


On Fri, Sep 17, 2010 at 9:08 AM, M. 427 <427 at free.fr> wrote:

> Hello,
>
> (I am very new to python)
> I built a dictionary d={} of lists similar to this :
>
> d = {
> 'a': ['apricot', 'apple'],
> 'b': ['beach', 'bear', 'bottle'],
> 'c': ['cold', 'cook', 'coleslaw'],
> 'd': ['deep'],
> 'e': ['expression', 'elephant']
> }
>
> Now i want to go through this dictionary and remove all rows containing
> only one entry. How should I do that?
>
> You can loop through all the entries in d, and remove the entries that have
length one.  Hope that isn't too much of a hint

>
> Question 2 : where should I have found this answer myself? (apart from
> here)
>
>
> Thank you for your help.
>
> Mr. 427
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100917/7a263040/attachment.html>


More information about the Tutor mailing list