
October 2nd, 2012, 06:07 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 15
Time spent in forums: 4 h 13 m 33 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by ika1020 I'm new to python, and for my assignment, I have to write a program, that when the wrong number of digits is given (in this case anything but 4-digits), it prints an error message. I have to set the boolean variable set valid to false & then stop.
It also has to give an error message if there are non-digits in my program. again, set valid to false & then stop.
does anyone have any help that could get me started? |
Not sure if you still need help, or if the above reply helped, but I would do it like this:
If given a number, and we want to return false if it is not 4 digits, then divide the number by 1000, and if the value is greater than or equal to 1, then we know it at least 4 digits, and if the value is greater than or equal to 10, we know it is more than 4 digits.
Hope that can help!
|