About 94,500 results
Open links in new tab
  1. How do I multiply each element in a list by a number?

    Feb 3, 2016 · Since I think you are new with Python, lets do the long way, iterate thru your list using for loop and multiply and append each element to a new list. using for loop lst = [5, 20 …

  2. How can I multiply all items in a list together with Python?

    Dec 12, 2012 · Given a list of numbers like [1,2,3,4,5,6], how can I write code to multiply them all together, i.e. compute 1*2*3*4*5*6?

  3. python - How to perform element-wise multiplication of two lists ...

    I want to perform an element wise multiplication, to multiply two lists together by value in Python, like we can do it in Matlab. This is how I would do it in Matlab. a = [1,2,3,4] b = [2,3,4,5] ...

  4. How do I multiple all integers in a list? --Python

    Jan 22, 2013 · list1= [1,2,3,4] 1) I want to multiply every element in this list in order to output 24. How do I do this in python without using a for loop? Are there in-built libraries to do this? 2) …

  5. python - How to multiply all integers inside list - Stack Overflow

    Oct 19, 2014 · Hello so I want to multiply the integers inside a list. For example; l = [1, 2, 3] l = [1*2, 2*2, 3*2] output: l = [2, 4, 6] So I was searching online and most of the answers were …

  6. python - How to multiply individual elements of a list with a …

    In Python S is not an array, it is a list. There is a very big difference betweeb the two types of containers. If you want numerical arrays, use numpy.

  7. python - Multiply elements of inner lists as a list comprehension ...

    You can use reduce() to apply multiplication to a list of integers, together with operator.mul() to do the actual multiplication: from functools import reduce from operator import mul products = …

  8. Multiplying Elements in a List in Python - Stack Overflow

    Dec 16, 2016 · Say I have a list alist = [6, 6, 6, 3, 1] And I want to multiply every element in the list by 4 and return alist = [24, 24, 24, 12, 4] My current approach is to iterate through the list and …

  9. multiply list elements in python - Stack Overflow

    Sep 3, 2017 · How do I multiply every element of one list with every element of another list in Python and then sum the result of the multiplying results variations? list_1 = [0, 1, 2, 3, 4, 5] …

  10. python - How do I multiply lists together using a function? - Stack ...

    Sep 26, 2013 · The problem with the original code is that it iterates the inner list (value) once for each iteration of the outer list (list). While there are many approaches below, the fundamental …

Refresh