i'm trying to compare a user input to a dic in python, the program should take the student id as an input, and return the student grade. and the program should follow some rules: 1- the length of the input must not be less than OR greater than 5, if so the program should return an error message. 2- if the ID isn't in the dic the program should also send an error message. i wrote the code below and when the input length is less than or greater than 5 the code works, but when the input length == 5 i get a looping message that says the ID not found even if the id is in the dic. the code :
students = {11111: "A+", 22222: "B+", 33333: "D+"}
ID = input("please enter the student ID:")
while len(str(ID)) == 5:
for key in students:
if ID == key:
print(students[int(ID)])
else:
print("ID not found")
if len(str(ID)) < 5:
print("invalid Id")
elif len(str(ID)) > 5:
print("invalid Id")