From 456ec8454dad8f961b569ed979752ed6349d30d9 Mon Sep 17 00:00:00 2001 From: annwarsa Date: Wed, 28 Feb 2024 14:21:30 +0000 Subject: [PATCH 1/2] Close #34844 Updated validations.py python script. Fixed the behavior of validate_user function in validations.py --- Course3/Lab4/validations.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index b18de65a2e..0f89dfbe11 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -13,12 +13,15 @@ def validate_user(username, minlen): if len(username) < minlen: return False # Usernames can only use letters, numbers, dots and underscores - if not re.match('^[a-z0-9._]*$', username): + if not re.match('^[a-z][a-z0-9._]*$', username): return False # Usernames can't begin with a number if username[0].isnumeric(): 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 6fe731bb1d7feb8894a825de53ae10bfee318e62 Mon Sep 17 00:00:00 2001 From: annwarsa Date: Wed, 28 Feb 2024 14:35:24 +0000 Subject: [PATCH 2/2] Close: #34844 Update validations.py python script. Fixed the behavior of validate_user finction in validations.py --- Course3/Lab4/validations.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index 0f89dfbe11..58b0c181ad 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -24,4 +24,3 @@ def validate_user(username, minlen): 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 -