Q. Write a Python function to multiply all the numbers in a list.


Sample List: (8, 2, 3, -1, 7)

Expected Output: -336


Answer =


def multi (x) :
    mul = 1
    for i in x :
        mul *= i
    print ("Answer after multiply:- ", mul)

lst = eval(input("Enter a List :- "))
multi(lst)

 


After running the program output is:-


Enter a List :- [8,2,3,-1,7]

Answer after multiply:-  -336

>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post