title: How do you replace all the occurrences of a words from a multi-line string which is user defined?
body: <p><a href="https://i.stack.imgur.com/sD3eQ.jpg" rel="nofollow noreferrer">image showing my output code</a></p>
  <p>I would like to replace the occurrence of word from the user-defined string with some other word that I input into my program.</p>
  <pre><code>lines = []
  #getting multi-line input from the user
  while True:
      line = input()
      if line:
          lines.append(line)
      else:
          break
  text = '\n'.join(lines)
  print(text)
  
  # word count
  total_char = 0                      #total char
  total_w = 1                         #total words
  for i in range(len(text)):
      if(text[i] == ' ' or text[i] == '\n'):
           total_w += 1         
  print(&quot;Total no. of words: &quot;,total_w)
  
  #char count
  for j in range(len(text)):
      total_char += 1
  print(&quot;The total number of characters: &quot;,total_char)
  </code></pre>
  <p>Here is my program output image. I just wanna count the occurrence of the repeated word from user input and replace it by some other random word.</p>