title: Replacing all instances of a character in a string using python
body: <p>trying to replace all instances of a given character in a string with a new character. The following is my code:</p>
  
  <pre><code>def main():
      s='IS GOING GO'
      x='I'
      y='a'
  
     rep_chr(s,x,y)
  
  
  def find_chr(s,char):
      i=0
      for ch in s:
          if ch==char:
              return (i)
              break        
          i+=1
      return -1
  def rep_ch(s,x,y):
      result=""
  
      for char in s:
  
          if char == x:
              print(result=result+ y )        
          else:
              return char   
  main()
  </code></pre>
  
  <p>Edited the code, but it is still replacing the first 'I' with 'a' and ignoring the second 'I'. Any suggestion?</p>