Product of Elements in the List
You are given a space-separated list of integers as input. Write a program to print the product of these numbers.
The first line of input contains space-separated integers.
In the example, there are
6 numbers, 1, 2, 3, 4, 5, 6.The product of list elements is
1 x 2 x 3 x 4 x 5 x 6 So, the output should be 720.
Sample Input :
1 11 13 21 19
Sample Output:
57057
Nums = str(input("Enter Numbers separated by SPACE: ")).split(" ")
print(Nums)
Prod = 1
s = ""
for r in range(0,len(Nums)):
Prod = Prod * int(Nums[r])
s = s + Nums[r] + " x "
print("Product of list (",s,") = ",Prod)
Comments
Leave a comment