+ 2
How should I add a block of code to limit input to numbers only?
The program is for the creation of a bank card pin. The user input should consist of four digits between 0 and 9 and should raise an exception if : 1. The digit count is not equal to 4. 2. The intended pin includes any character outside 0-9. https://code.sololearn.com/cfRRiWr4Od88/?ref=app
2 Answers
+ 4
You could do it with a while loop. Ask for input (one digit) 4 times, and each time check if the input is a int, otherwise, ask again for the input.
At the end, if the input is int, add the number to a string so you can have the whole number.
(it may not work on sololearn due to input being different)
+ 3
Hi!
inpit --->>>input