A22.0002 Samuel Marateck

ASSIGNMENT 2. MW class assigned MON SEPT 24 due THURS OCT 4 11:59 pm

This assignment is just like the first one except that it should be robust. So if you type in the wrong number of digits, your program should print an error message, set the boolean variable valid to False and then stop. For example:

type your 4-digit int 
64312
5  is the wrong number of digit

Hint: use the len() function.

If you type a non-digits in your input, your program should print an error message, set valid to False and then stop. For example:

type your 4-digit int 
12u4
u is an invalid digit

Hint: use for c in s: . Each character has been assigned an ASCII code (American Stadard Code for Information Interchange). The ASCII codes for the digits are contiguous, i.e., they are grouped together. So if you want to test for a non-digit, you must test for not a digit. Use the not in front of the test for a digit.

If you input is valid (valid is True), the output should be the same as in the first program