Checking that a user input has four digits
how do you check that a user input has four digits?
You are viewing a single comment. View All
Answered by TimothyAnderso1 (65) [earned 5 cycles]
The best way would be similar to what Archie suggested, but first convert it to a string which would make the code look something like this
x = input () if len(str(x)) == 4: # the input has 4 characters/digits else: # the input does not have 4 characters/digits.