An e-commerce application wants to give discounts to its customers. The discount is calculated as the product of the sum of even numbers and the sum of odd numbers present in the bill. Print the discount that a customer can get.
1. Input: 2345, Output: 48
Explanation: even_sum = 2+4 = 6.
Odd_sum = 3+5 = 8.
Product = 6*8 = 48.
def dis_app(numbers):
r = 0
s = 0
for i in numbers:
if i % 2 == 0:
r = r + i
else:
s = s + i
return r * s
dis_app([4,5,6,7])
Comments
Leave a comment