title: How to slice arrays using variables and iterate?
body: <p>I am trying to store <code>Val = [32, 43, 26, 50, 20, 27]</code> and <code>wt = [16, 12, 4, 8, 3, 9]</code>, how do I do this through iterating and slicing via variables? </p>
  
  <pre><code>res = [4, 2, 77, 7, 66, 6, 2, 5, 5, 6, 32, 16, 43, 12, 26, 4, 50, 8, 20, 3, 27, 9]
  </code></pre>
  
  <p>Before the below </p>
  
  <pre><code>len(val) = 3, len(wt) = 3  F = 1 
  val = [77, 66]
  wt = [7, 6]
  
  
  
  elif(tCount &gt; 0):
      N = res[len(val)+len(wt)+F*2+1]
      print("N equals" +str(N))
  
  
  
      val = res[N * 2:2]
      wt = res[3:3 + N * 2:2]
      print(val)
      print(wt)
      print(F)
      print(W)
  </code></pre>
  
  <p>How do I store N to = 6? Then slice the array for val and wt for the next section.</p>
  
  <p>EDIT - My aim is to store N = 6 then, store val with 6 values [32, 43, 26, 50, 20, and 27] wt with [16, 12, 4, 8, 3 and 9] and then I will be passing these into the following function solve(val, W, wt, N, F)</p>