Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.
string = input()
count = 0
sum = 0
for symb in string:
if symb.isdigit():
sum += int(symb)
count+=1
print(f'Sum: {sum}')
print(f'Average of the digits: {sum/count}')
Comments
Leave a comment