title: Python : replace multiple occurrence of characater by one but single occurrence by none
body: <p>I have a string: </p>
  
  <pre><code>a = '0202201131181'
  </code></pre>
  
  <p>I want to replace all multiple occurrences of <code>1</code> in <code>a</code> if present, by a single <code>1</code> but if only one occurrence of '1' is found then replace it by empty string ''.</p>
  
  <p>My end goal is to get:</p>
  
  <pre><code>a = '0202201318'
  </code></pre>
  
  <p>Here the '1' after character '8' is occurring only once, so it's replaced by empty string, but the '11' before the character '3' and after the character, '3' is replaced by '1'.</p>
  
  <p>Here is an if-else code block I tried, which is partially correct:</p>
  
  <pre><code>if '11' in a:
      a = a.replace("11","1")
  else:
      a = a.replace("1","")
  </code></pre>
  
  <p>But it outputs <code>'02022013181'</code>, which is incorrect. How to do this?</p>