how can we define (1,2,3,4,5,6,7,8,9) so *args take 1,2,3,7,8
<p>Suppose we have a function with variable length parameter but i want some specific values to taken by variable length parameter ??</p>

<p>example :</p>

<pre><code>def hello(a,*args,b=10):
    pass
hello(1,2,3,4,5,6,7,8,9)
</code></pre>

<blockquote>
  <p>how can we define (1,2,3,4,5,6,7,8,9) so *args take 1,2,3,7,8 ?? other values can be taken by a or b or you can add more parameters to take remaining values i just want that *args should take only 1,2,3,7,8 remaining taken by other parameters.</p>
</blockquote>

<p>If you want <code>*args</code> to be the 1st, 2nd, 3rd, 7th and 8th argument, you should make the function just take <code>*args</code> and then make the other args into a seperate variable.</p>

<pre><code>def hello(*args, b=10):
    other_args = args[3:6] + args[8:] # Takes the fourth, fifth, sixth and ninth and onward
    args = args[:3] + args[6:8] # Takes first, second, third, seventh and eighth args
hello(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, b=11)
# -&gt; args == (1, 2, 3, 7, 8)
#    other_args == (4, 5, 9, 10)
#    b == 11
</code></pre>

python python-2.7 python-3.x