Python program to Get Sum and Products of Digits
str1 = str(input("Insert values only: "))
sum_digit = 0
pro_digit = 1
for x in str1:
if x.isdigit() == True:
z = int(x)
sum_digit = sum_digit + z
pro_digit *= z
print("Sum of digits = ",sum_digit)
print("Product of digits = ", pro_digit)
Output:
|
Insert values only: 123
Insert values only: 435 |