Not Equal to Each Other?
aleax at mail.comcast.net
Fri Nov 4 03:42:34 CET 2005
<ale.of.ginger at gmail.com> wrote:
> Rather than writing
> cellboard is not* (cellboard and cellboard and cellboard
> and cellboard ... cellboard)
> cellboard is not (cellboard and cellboard and cellboard and
> cellboard ... cellboard)
Urgh... the fastest way to check that a list of N numbers has no
if len(set(thelist)) == len(thelist):
print 'no duplicates'
But if your purpose is to generate N random samples out of a population
of M, look at function random.sample (in module random in the Pythons
standard library) and you'll do even better!-)
More information about the Python-list