title: Replacing the 2nd occurence of a set of characters with a corresponding set of characters in python
body: <p>Aim of program: To replace
  a/A with 4,
  e/E with 3,
  i/I with !,
  o with ooo,
  O with 000,
  such that on every 2nd occurrence of each character the replacement is made</p>
  <p>&quot;aAa eEe iIi oOo uUu&quot; should result in the program printing &quot;a4a e3e i!i o000o u|_|u&quot;</p>
  <p>If the 2nd o is capital, it is replaced with 000. If the 2nd o is lowercase, it is replaced with ooo.</p>
  <pre><code>def vowel_swapper(string, a, b):
     return string.replace(a, b, 2).replace(b, a, 1)
  
  string = input(&quot;Enter:&quot;)
  vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
  replacement = ['4', '3', '!', 'ooo', '|_|', '4', '3', '!', '000', '|_|']
  
  for i in range(9):
     newstring = vowel_swapper(string, vowels[i], replacement[i])
     string = newstring
  
  print(newstring)
  </code></pre>
  <p>This just outputs
  aAa eEe iIi oOo uUu --&gt; aA4 eE3 iI! oOooo uU|_|</p>
  <p>as it doesn't avoid the upper/lower case problem. Please could somebody help me out?</p>