title: Printing a list with elements depending on size of list
body: <p>I have a list of integers and I want to print a list containing, for example, k number of elements in the list depending on the "k" value.</p>
  
  <p>For example, if k = 4, this means that the list I will be printing will have exactly 4 elements in the list. For k = 5, 5 elements in the list, etc.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>listA = [9,-2,6,1,80,9,-2]
  
  def findMinimum(l):
      if len(l) == 1:
          return l[0]
  
      else:
          minNumber = findMinimum(l[1:])
          minimumVal = l[0]
          if minNumber&lt;minimumVal:
              minimumVal = minNumber
          return minimumVal
  
  def listMin(k,l):
      temp = []*k
      for i in range(len(l)-1):
          minVal = findMinimum(l)
          temp.append(minVal)
  
          for item in temp:
             if item in l:
                l.remove(item)
      print(temp)
  
  listMin(4,listA)
  </code></pre>
  
  <p>The <strong>first function</strong> defined finds the <strong>minimum value</strong> in the list and returns the minimum value.</p>
  
  <p>The <strong>second function</strong> has 2 parameters which are the k value and list. The <strong>k value is the size of the list to return</strong> which I'm having issues on. Whenever a minimum value is obtained and appended into the temp list, it <strong>removes</strong> it from <strong>list A</strong> and will then proceed on to obtain the next minimum digit in the list <code>A</code>.</p>
  
  <p>An example of output will be when k = 4, hence the list will have four elements in it:</p>
  
  <pre><code>[-2,-2,1,6]
  </code></pre>
  
  <p>The code I wrote gave me 6 elements in the list instead of 4:</p>
  
  <pre><code>[-2,-2,1,6,9,9]
  </code></pre>
  
  <p>I'm guessing my mistake would be temp = []*k.</p>