title: How to print the strings having repeating characters?
body: <p>The question is that:</p>
  <p><em>Suppose I have a string <code>S='ABC'</code>, then I want the output to be this list<code>['AAA','BBB','CCC','AAB','ABB','AAC','ACC','BBC','BCC']</code></em></p>
  <p>How do I achieve this result?</p>
  <p><strong>Edit:</strong> Thanks to <strong>@Breno Monteiro</strong>, I came up with the solution based on the example he had shown. What I did was produced the list <code>['AAA','BBB','CCC']</code> at first, by multiplying 3 with each of the characters. After that, I replaced the first and second index of the each of the elements in <code>['AAA','BBB','CCC']</code> by the second character in the string i.e., if the character is <code>'A'</code> then its replaced by <code>'B'</code>, if its <code>'C'</code>, then its replaced by <code>'A'</code> and so on and so forth. So the real output came out to be <code>['AAA', 'BBB', 'CCC', 'BAA', 'BBA', 'CBB', 'CCB', 'ACC', 'AAC']</code></p>
  <p><strong>My code:</strong></p>
  <pre><code>string='ABC'
  K=3
  output=['AAA','BBB','CCC','AAB','ABB','AAC','ACC','BBC','BCC']
  s=&quot;&quot;
  exp_output,temp=[],[]
  ind=1
  #including all repeating characters in the string
  for i in string:
      s+=i*K
      exp_output.append(s)
      s=&quot;&quot;
  
  #including all repeating characters by the first and second index
  for i in exp_output:
      for j in range(K-1):
          i=i.replace(i[j],string[ind%len(string)],1)
          temp.append(i)
          #print(temp)
      ind+=1
  exp_output.extend(temp)
  
  print(exp_output)
  </code></pre>