I am right now a gr.10 student who is studying basic computer programming, my assignment had the following description: e a 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, and here is what I had come up with:
(I will add that this is python 3)
def value(string): count = 0 for num in str(string)[0:]: if num.isdigit() and int(num) in range(10): count += int(num) return count def main(): user_input_string = input('Enter a string of single digit number: ') print('That string has a total value of: ' + str(value(user_input_string)) + '.') main()can you pls help me as soon as possible and figure out how to write a proper code in order to enter one digit at a time
(I will add that this is python 3)