How to take multiple values from a python list?
<p>I am creating a program that takes user input stores it in a list and then multiplies by either 5 or 1 alternating between each number. eg the first value is multiplied by 5 and the next 1 and so on. I want to remove all the values that i would multiply by 5 and add them to a separate list. How would this be done? </p>

<pre><code>list1=[1,2,3,4]
list2=List1[???]
</code></pre>

<p>Here you go:</p>

<pre><code>list1=[1,2,3,4]
list2 = [i*5 for i in list1[1::2]]
</code></pre>

<p>Two methods are used here <a href="https://docs.python.org/2.3/whatsnew/section-slices.html" rel="nofollow">slicing</a> and <a href="http://www.secnetix.de/olli/Python/list_comprehensions.hawk" rel="nofollow">list comprehension</a>.</p>

python