CBSE Class 12 Computer Science Question 37 of 57

Review of Python Basics — Question 37

Back to all questions
37
Question

Question 32

Write a Python program to multiply all the items in a list.

Solution
lst = eval(input("Enter the list: "))
result = 1
for item in lst:
    result *= item
print("Result:", result)
Output
Enter the list: [1, 2, 3, 4, 5, 6]
Result: 720
Answer

lst
=
eval
(
input
(
"Enter the list: "
))
result
=
1
for
item
in
lst
:
result
*=
item
print
(
"Result:"
,
result
)
Output
Enter the list: [1, 2, 3, 4, 5, 6]
Result: 720