The argument is entered as a list (ie. [4,5,6]). But how can I get the output as a list and not just integers
<p>The output I was getting was just integers (ie. 2,6,9). Desired output was a list (ie. [2,6,9] ). </p>

<pre><code>def multiplyNums(aList):
    for (i,j) in enumerate(aList):
        newList = []
        if i &lt; (len(aList)-1):
            newList = (aList[i] * aList[i+1])
            x = print(newList,end=',')
        else:
            newList = (aList[i] * aList[i])
            x = print(newList)
    return x
</code></pre>

<p>Is it that you would like to produce a list which contains the value of each entry multiplied by the following value (and the last value squared)?</p>

<p>ie.  [2,3,4] -> [2*3, 3*4, 4*4]  ?</p>

<p>If so then I think you should probably do:</p>

<pre><code>def multiplyNums(aList):
    newList = []
    for (i,j) in enumerate(aList):
        if i &lt; (len(aList)-1):
          newList.append(aList[i] * aList[i+1])
        else:
          newList.append(aList[i] * aList[i])
    return newList


print multiplyNums( [2, 3, 4] )
</code></pre>

<p>Here is a funny single line list comprehension:</p>

<pre><code>def multiplyNums(a):
    return [x[0]*x[1] for x in zip(a,a[1:]+[a[-1]])]
</code></pre>

python list