Answer to Question #277628 in Python for Daniel

Question #277628

Write a python program to count number of digits in a given username. Show the first and last digits of the number, and summation of all the digits.

1
Expert's answer
2021-12-10T00:36:48-0500
n = input()


count = 0
sum = 0
for i in range(0,len(n)):
    if n[i].isdigit():
        sum = sum + int(n[i])
        count += 1


print('count = ',count)
print('sum  = ',sum)

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