3
Checking that a user input has four digits
IsobelBolter (2)

how do you check that a user input has four digits?

You are viewing a single comment. View All
Answered by TimothyAnderso1 (55) [earned 5 cycles]
View Answer
1
Dopest_Pleb (15)

Check if the length of their input is equal to 4. If it is, convert their input to an integer. Put this inside a try statement that catches a ValueError. Inside the catch you can continue the while loop to ask them again. If an error is not caught, then write the rest of the code for the program.

Here is my example: https://repl.it/@Dopest_Pleb/Bulls-and-cows