From 862bdb7d95d636472e0da2ade1584b80b993d5c5 Mon Sep 17 00:00:00 2001 From: Bekzod Ochilov Date: Thu, 24 Apr 2025 00:57:16 +0000 Subject: [PATCH] Closes: #1 Updated validations.py python script. Fixed the behavior of validate_user function in validations.py. --- Course3/Lab4/validations.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index b18de65a2e..fcf71eed40 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -16,9 +16,17 @@ def validate_user(username, minlen): if not re.match('^[a-z0-9._]*$', username): return False # Usernames can't begin with a number - if username[0].isnumeric(): + if not username[0].isalpha(): return False + + return True +print(validate_user("blue.kale", 3)) # True + +print(validate_user(".blue.kale", 3)) # Currently True, should be False + +print(validate_user("red_quinoa", 4)) # True +print(validate_user("_red_quinoa", 4)) # Currently True, should be False