From 3f477c2b85529c94fcb82f9e02ffa4e4a5e69d68 Mon Sep 17 00:00:00 2001 From: JH Date: Sun, 5 Jan 2025 14:48:55 +0000 Subject: [PATCH 1/2] corrected function --- Course3/Lab4/validations.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index b18de65a2e..a74bd58e36 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -18,7 +18,15 @@ def validate_user(username, minlen): # Usernames can't begin with a number if username[0].isnumeric(): return False + if not re.match('^[a-z]*$', username[0]): + 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 From a448285dd034b51c0327ddcfac95b632b60693a1 Mon Sep 17 00:00:00 2001 From: JH Date: Sun, 5 Jan 2025 14:51:43 +0000 Subject: [PATCH 2/2] Closes: #1 Updated validations.py python script. Fixed the behavior of validate_user function in validations.py. --- Course3/Lab4/validations.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index a74bd58e36..5348559eba 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -21,11 +21,9 @@ def validate_user(username, minlen): if not re.match('^[a-z]*$', username[0]): return False - return True - - +# run checks 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