title: Python. <Remove Element> in a list
body: <p>Title:</p>
  <blockquote>
  <h3><a href="http://www.lintcode.com/en/problem/remove-element/" rel="nofollow noreferrer">172. Remove Element</a></h3>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/1wLIn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1wLIn.png" alt="enter image description here" /></a>
  Description:</p>
  <blockquote>
  <p>Given an array and a value, remove all occurrences of that value in place and return the new length.</p>
  <p>The order of elements can be changed, and the elements after the new length don't matter.</p>
  </blockquote>
  <p>My Answer:</p>
  <blockquote>
  <p><strong>On LintCode</strong></p>
  </blockquote>
  <pre><code>def removeElement(self, A, elem):
  # write your code here
      if A == []:
          return A
      if elem in A:
          sortedA = sorted(A)
          li = []
          for i in xrange(len(sortedA)):
              if sortedA[i] == elem:
                  li += [i]
          newLength = sortedA[:min(li)] + sortedA[max(li)+1:]
          return newLength
      else:
          return A
  </code></pre>
  <blockquote>
  <p><strong>On my mac</strong></p>
  </blockquote>
  <pre><code>A = [0,4,4,0,0,2,4,4]
  elem = 4
  def sss(A, elem):   
      if A == []:
          return A
      if elem in A:
          print A
          sortedA = sorted(A)
          print sortedA
          li = []
          for i in xrange(len(sortedA)):
  #           print type(i)
              if sortedA[i] == elem:
                  li += [i]
                  print li
          newLength = sortedA[:min(li)] + sortedA[max(li)+1:]
          print newLength
          return newLength
      else:
          return A
          
  print sss(A, elem)
  </code></pre>
  <p>This answer <strong>On my mac</strong> work's good, but <strong>On LintCode</strong> doesn't accept.</p>