[Baypiggies] list question

Vikram K kpguy1975 at gmail.com
Wed Apr 6 04:49:51 CEST 2011

i have this list:
x = ['cat','dog','dog']

i wish to identify the non-unique element in this list i.e. 'dog'. how do i
do this?

i did this:

>>> y = list(set(x))
>>> y
['dog', 'cat']

but now i don't know to proceed further. have tried the following:

>>> z = [i for i in x if i in y]
>>> z
['cat', 'dog', 'dog']

>>> z = x - y
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    z = x - y
TypeError: unsupported operand type(s) for -: 'list' and 'list'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20110405/db03345d/attachment.html>

More information about the Baypiggies mailing list