def Input_stdid():
stdId=""
while 1:
stdId_temp=0
stdId_temp=input("Input stdudent id: ")
for i in stdId_temp:
if i in "0123456789" and len(stdId_temp)==8:
stdId+=str(i)
else:
print("Wrong Input!")
Input_stdid()
break
Input_stdid()
We're working on a code that is a number and needs to be entered in 8 digits at the same time. There is no problem if you enter 8 digits in the first attempt, but if you enter 8 digits after entering 3 digits and 5 digits incorrectly at first, you will still get Wrong Input What's the problem?
python
The same phenomenon as the question occurred because I misunderstood the reflexes and wrote them.
Perhaps the code the questioner wanted was as follows.
def Input_stdid():
while True:
numbers = input("Input stdudent id: ")
if numbers.isnumeric() and len(numbers) == 8:
return numbers
else:
print("Wrong Input!")
561 PHP ssh2_scp_send fails to send files as intended
554 Uncaught (inpromise) Error on Electron: An object could not be cloned
788 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
555 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.