Print the product of positive number
Problem to product the positive numbers only in given list.
Example-1:
Input : n = [ -3, 1, -5, -2, -7, 5] Output : 5 Explain : positive numbers are 1,5. 1 * 5 = 5.
Example-2:
Input : n = [ -6, -1, 2, 4, -7, 5] Output : 40 Explain : positive numbers are 2,4,5. 2*4*5 = 40.
Solution
n = [ -3, 1, -5, -2, -7, 5] k = 1 for x in n: if(x>0): k *= x print(k)
Output
5