Answer to Question #231252 in Python for bhuvana

Question #231252

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.


1
Expert's answer
2021-08-31T17:36:11-0400
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}')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS