Multiply All Numbers in the List in Python Last Updated : 03 May, 2025 Comments Improve Suggest changes Like Article Like Report Our task is Multiplying all numbers in a list Using Python. This can be useful in calculations, data analysis, and whenever we need a cumulative product. In this article we are going to explore various method to do this. Using a loopWe can simply use a loop (for loop) to iterate over the list elements and multiply them one by one. Python a = [2, 4, 8, 3] res = 1 for val in a: res = res * val print(res) Output192 Explanation: We start with res = 1 and then multiply each number in the list with res using a for loop.Using math.prod()The math library in Python provides the prod() function to calculate the product of each element in an iterable.Note: The prod() method was added to the math library in Python 3.8. So, it only available with Python 3.8 or greater versions. Python import math a = [2, 4, 8, 3] res = math.prod(a) print(res) Output192 Explanation:a = [2, 4, 8, 3]: A list of integers.math.prod(a): Multiplies all elements in the list (2 * 4 * 8 * 3).print(res): Outputs the result of the multiplication (192).Using reduce() and mul()We can use reduce() function from the functools module, which can apply a function to an iterable in a cumulative way. We can use the operator.mul() function to multiply the elements together. Python from functools import reduce from operator import mul a = [2, 4, 8, 3] res = reduce(mul, a) print(res) Output192 Explanation:a = [2, 4, 8, 3]: A list of integers.reduce(mul, a): Applies the mul operator (multiplication) cumulatively to the elements of a (i.e., 2 * 4 * 8 * 3).print(res): Outputs the result of the multiplication (192).Related Article:Multiple List Elements Using numpy.prod()Find Sum of all Elements in a ListFind Average of All Elements in a ListLoops in Python – For, While and Nested LoopsPython – math.prod() methodreduce() in Python Python program to multiply all numbers in the list Comment More infoAdvertise with us Next Article Must Coding Questions - Company-wise S Striver Follow Improve Article Tags : Misc Python Python-numpy python-list Python list-programs +1 More Practice Tags : Miscpythonpython-list Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like