title: Problems outputting defined string with a defined weights ( in python)
body: <p>I've spent the last few hours trying to figure how to do something relatively simple- i'd like to write a python script that returns a number of strings from a predefined alphabet using certain weights. So for example</p>
  <pre><code>strings = 3
  length= 4 
  alphabet = list('QWER')
  weights=[0.0, 0.0, 0.0, 1.0]
  </code></pre>
  <p>this would return</p>
  <pre><code>RRRR RRRR RRRR 
  </code></pre>
  <p>or another example</p>
  <pre><code>strings = 2
  length= 3 
  alphabet = list('ABC')
  weights=[0.3,0.3,0.3]
  </code></pre>
  <p>This would return</p>
  <pre><code>CBA ABC CAA
  </code></pre>
  <p>I've tried playing around with a number of example codes and this is the closest i've come-</p>
  <pre><code>import random
  
  import numpy as np
  
  LENGTH = 3
  NO_CODES = 100
  
  alphabet = list('ABCD')
  weights=[0.0, 0.0, 0.0, 1.0]
  np_alphabet = np.array(alphabet, dtype=&quot;|U1&quot;)
  np_codes = np.random.choice(np_alphabet, [NO_CODES, LENGTH])
  codes = [&quot;&quot;.join(np_codes[i]) for i in range(len(np_codes))]
  print(codes)
  </code></pre>
  <p>However, i know i'm not using the weight function correctly. If anyone can tell me what i'm doing wrong or suggest a better way to do it, that would be appreciated. As i'm sure you can tell i don't really know what i'm doing, so any advice would be useful.</p>