Question: IN python and ( No dictionaries, classes ) but you can use Functions, strings, lists, sets, loops if else also no breaks are allowed or

IN python and (No dictionaries, classes) but you can use Functions, strings, lists, sets, loops if else also no breaks are allowed or continue statemetns and no global variables
Write a program that asks the user to enter a single-digit number sequentially with nothing separating them. The single-digit number must be inputted as a string not an int or float. Then display the sum of all the single digit numbers in the single-digit string
The main() function template is provided for you below. Write the codes for the function string_total(). You are not allowed to change anything in the main function template (add, delete or change). Changing any single piece of code in the given main function template will result in a zero for this question. The main() function must be placed at the bottom after all other functions.
def main():
# Get a string of numbers as input from the user.
number_string = input('Enter a sequence of digits with nothing separating them: ')
# Call string_total function, and store the total.
total = string_total(number_string)
# Display the total.
print('The total of the digits in the string you entered is', total)
**all functions must include docstrings and type hints(annotations). Programs with functions must have the statement at the end of the program before calling the main() function. Functions must be separated with 2 blank line spacings.
if __name__=="__main__":

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!