Homework 3
assigned assigned WED OCT 17 due THR OCT 25 at 11:59 pm

Write a function called plot(s) in which s is a string representing a social security number written as contiguous digits (for instance, 509435456). It then prints each digit on a separate line followed by a colon and the digit printed the number of times equal to its value. Thus the output for 509435456 would be

 5:55555
 0:
 9:999999999
 4:4444
 3:333
 5:55555
 4:4444
 5:55555
 6:666666

You must do this two ways: the first way using a nested loop; the second way without a nested loop. Thus there will be two submissions each worth a maximum of 2 points. Note that a for loop, for instance, beginning with for j in range(0) is executed zero times.

Your string should be read in the main() function and transferred to the dummy parameter s in plot(s). In the non-nested loop version, the input must be a nine-character string and contain no non-digits. The robustness of the data should be tested in the main() function. If the input is not valid, your program should prompt the user again to input data until the input is valid. Use a while for this. The form of the while should be

invalid = True
while invalid:
When valid data is read, the variable invalid should be set to False, otherwise the user should be told that his data was faulty and should retype the input .

Hint: Write the non-nested loop version in two stages, the first assumes valid data. Once this version works, test for data robustness. Submit the nested loop version and only the robust non-nested loop version.