col2_set = sets.Set(col2)
how can I get a uniq elements that repeated several times:
for item in range(len(list)): for k in range(len(list)): if item == k: if list[item] != k[list]: print item
First off, this would never work. You are iterating over the same list so go through each step on paper or in your head.
Oh, and don't use list for a variable name--it's a builtin function that you don't want to write over.
An example
a = [1,1,4,2,3,1,5]
for item in range(len(a)):
for k in range(len(a)):
if item == k:
if a[item]!=a[k]: ## I think this is what you meant to put--otherwise you would be trying to index an index!
print item ## This returns an index, maybe you want the element instead?
Ok... here's how it runs with all the variables replaced with the values defined by the loop.
if 0 == 0: if 1!=1: print 1
That is okay.
if 0 == 1:
if 1 != 1: ## The first 1 comes from a[0] (item=0), the second 1 from a[1] (k=1)
print 1 ## This is obviously not what you want, so immediately we see a problem.
Then it goes through (0,2),(0,3),......(1,0),(1,1)(1,2),........(2,0),(2,1),....
Anyway, this is all irrevelant because sets takes care of doubles.
Set([1, 2, 3, 4, 5])import sets a = sets.Set([1,2,1,4,3,5,5,2,3,3,2]) a
[1, 2, 3, 4, 5]list(a) ## This is one of the uses of the builtin list -- to make a list of an iterable.
HTH, Jacob
This isnt working either. logic appears correct. looking forward for help pleas.
thank you
Srini
__________________________________ Do you Yahoo!? The all-new My Yahoo! - What will yours do? http://my.yahoo.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor