[Tutor] Recommendation For A Complete Noob

Dave Angel davea at davea.name
Wed Feb 12 01:58:19 CET 2014


 Bob Williams <linux at barrowhillfarm.org.uk> Wrote in message:
 

> to slice those lines to get the artist and album
> names into a list.
> 
> So far, so good but my output contains duplicates, so my final task is
> to work out how to get rid of them.
> 


Hint: a set will contain only one of each item. So if you have a
 list of immutable items, the following will eliminate
 duplicates:

newlist = list (set (oldlist))

Sometimes a dict is better,  if only part of each item is to be
 made unique.

This assumes that order doesn't matter.  If it does, perhaps an
 ordered dict.

-- 
DaveA



More information about the Tutor mailing list