How to find duplicate elements in array using for loop in python like c/c++?
<p>i have a list with duplicate elements:</p>

<p>In python:</p>

<pre><code> list_a=[1,2,3,5,6,7,5,2]

 tmp=[]

 for i in list_a:
     if tmp.__contains__(i):
         print i
     else:
         tmp.append(i)
</code></pre>

<p>i have used the above code to found the duplicate elements in the list_a.
i dont want to remove the elements form list.</p>

<p>But i want to use for loop here:
Normally C/C++ we use like this i guess:</p>

<pre><code> for (int i=0;i&lt;=list_a.length;i++)
     for (int j=i+1;j&lt;=list_a.length;j++)
         if (list_a[i]==list_a[j])
             print list_a[i]
</code></pre>

<p>how do we use like this in Python ?</p>

<pre><code>for i in list_a:
    for j in list_a[1:]:
    ....
</code></pre>

<p>i tried the above code .But it gets solution wrong.i dont know how to increase the value for j.pls help...            </p>
