title: Repeat items in list to required length
body: <p>I have a list of available items that I can use to create a new list with a total length of 4. The length of the available item list never exceeds 4 items. If the list has less than 4 elements I want to populate it with the available elements beginning at the start element.</p>
  
  <p>Example 1:</p>
  
  <pre><code>available_items = [4, 2]
  Result -&gt; [4, 2, 4, 2]
  </code></pre>
  
  <p>Example 2:</p>
  
  <pre><code>available_items = [9, 3, 12]
  Result -&gt; [9, 3, 12, 9]
  </code></pre>
  
  <p>Example 3:</p>
  
  <pre><code>available_items = [3]
  Result -&gt; [3, 3, 3, 3]
  </code></pre>
  
  <p>I have the feeling that my solution is not optimal, but I have found nothing better so far:</p>
  
  <pre><code>available_items = [3, 5]
  required_items = 4
  
  if len(available_items) == 1:
    new_items = [available_items[0]] * required_items
  else:
    new_items = available_items + []
    for i in range(required_items - len(available_items)):
      new_items.append(available_items[i])
  
  print(new_items)
  </code></pre>