-2

In,

a=int(input("Enter A Integer: "))

How Can I Prevent The User From Entering More Than 4 Digits In This Input

1 Answers1

0

You cannot prevent user from entering as many digits he want, but you can always check the size, and prompt the user to reenter if it exceeds it.

a=10001
while a > 9999 :
    a = int(input("Enter A Integer less than 9999: "))

Of course you would need exception handling if he passes a string instead of number.

Prakhar Londhe
  • 1,431
  • 1
  • 12
  • 26