title: check for duplicates in a python list
body: <p>I've seen a lot of variations of this question from things as simple as remove duplicates to finding and listing duplicates.  Even trying to take bits and pieces of these examples does not get me my result.</p>
  
  <p>My question is how am I able to check if my list has a duplicate entry?  Even better, does my list have a non-zero duplicate?  </p>
  
  <p>I've had a few ideas - </p>
  
  <pre><code>#empty list
  myList = [None] * 9 
  
  #all the elements in this list are None
  
  #fill part of the list with some values
  myList[0] = 1
  myList[3] = 2
  myList[4] = 2
  myList[5] = 4
  myList[7] = 3
  
  #coming from C, I attempt to use a nested for loop
  j = 0
  k = 0
  for j in range(len(myList)):
      for k in range(len(myList)):
          if myList[j] == myList[k]:
              print "found a duplicate!"
              return
  </code></pre>
  
  <p>If this worked, it would find the duplicate (None) in the list.  Is there a way to ignore the None or 0 case? I do not care if two elements are 0.</p>
  
  <p>Another solution I thought of was turn the list into a set and compare the lengths of the set and list to determine if there is a duplicate but when running set(myList) it not only removes duplicates, it orders it as well.  I could have separate copies, but it seems redundant.</p>