I was writing A function to check if the user inserted a good string that can be counted as a username , python would return True, Else It would return False .
But the problem Is no matter how long the user inserted String Is , It would always return True , I'd be glad if Someone could Help me out.
# Define a function that will check the Chosen UserName , And see If it meet's the minimum Requirement's.
def isusername(UserName : str):
UserName_Last_Limit = 13
UserName_First_limit = 3
UserName_Lengh = len(UserName)
UserName_Lengh = UserName_Lengh + 1
if UserName.isdigit():
return False
# Define A list of allowed character's that can be used in In the character's Of a username.
allowed = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , ]
for character in UserName:
if UserName_Lengh > UserName_Last_Limit :
return False
elif UserName_Lengh < UserName_First_limit:
return False
elif character not in allowed:
return False
else:
return True
if isusername("Kh"):
print("True")
else:
print("False")