DAY 19 of PYTHON top 100 questions : from Basic to Advanced !!

DAY 19 of PYTHON top 100 questions : from Basic to Advanced !!

Write a Python program to find the product of all elements in an array :

l=[2,2,2,2,2]
mul=1
for i in l:
    mul=mul*i
print(mul)

Output :

32

The code essentially multiplies each element in the list together, starting with an initial value of 1 for mul, and updates mul in each iteration.


If you are a beginner and want to know more about Python programming, you can read my Basics of Python blogs (From part 1 to part 15).


HAPPY LEARNING !!!