Join list from specific index
<p>I have a list like below:</p>

<pre><code>ingredients = ['apple','cream','salt','sugar','cider']
</code></pre>

<p>I want to join this list to get a string but I want to join from 2nd index till the last one.</p>

<p>to get this : <code>"salt sugar cider"</code>
Length of list may vary.</p>

<p>Is it possible to do this with join function or I have to do it by looping over elements?</p>

<p>Just <a href="http://stackoverflow.com/questions/509211/explain-pythons-slice-notation"><em>slice</em> the list</a>:</p>

<pre><code>&gt;&gt;&gt; l = ['apple', 'cream', 'salt', 'sugar', 'cider']
&gt;&gt;&gt; ' '.join(l[2:])
'salt sugar cider'
</code></pre>

<p>We don't specify the end of the slice which means that it would slice to the last element of the list.</p>

python django list python-2.7