Lab6A2

Create a second program named Lab6A2 that will read an unknown number of integers from a text file and add up the digits in each number.
o Write a function named addDigits that will accept a string version of a number and will do the following:
▪ Convert the string number into a list of digits
▪ Loop through the list and convert each element to an integer.
Also add up the integers after you convert them.
▪ Return the total.
o Create a main function that will read an unknown number of integers from an input file. (Lab6A2.txt)
It should do the following for each number (remember that a number read from a text file is really a string):
▪ Call addDigits sending the number as a parameter.
▪ Print the number itself and the result returned from addDigits

×
New Download