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.
a. Input: 2345, Output: 48
Explanation: even_sum = 2+4 = 6.
Odd_sum = 3+5 = 8.
Product = 6*8 = 48.
def dis_app(list1):
r = 0
s = 0
for i in list1:
if i % 2 == 0:
r = r + i
else:
s = s + i
return r * s
dis_app([2,3,4,5])
48
Comments
Leave a comment