Ask Question
7 December, 07:25

Write a Python program that asks the user to enter a series of single-digit numbers with nothing separating them.

The program should display the sum of all the single-digit numbers in the string.

For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1 and 4.

+2
Answers (1)
  1. 7 December, 08:45
    0
    The Python 3 code for the program described in the question:

    def sum_digits (str):

    sum = 0

    for c in str:

    sum + = int (c)

    return sum

    def main ():

    print ("Enter series of single-digit numbers with no spaces: ")

    str = input ()

    print ("The sum of digits of the entered number is", sum_digits (str))

    main ()
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a Python program that asks the user to enter a series of single-digit numbers with nothing separating them. The program should ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers