From e6a9e610308cdafff36f7e9df695ce6f9b198c09 Mon Sep 17 00:00:00 2001 From: gulugulubing <413153391@qq.com> Date: Sun, 5 Jan 2025 05:18:05 +0000 Subject: [PATCH] Closes: #1 Updated validations.py python script. Fixed the behavior of validate_user function in validations.py. --- Course3/Lab4/validations.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Course3/Lab4/validations.py b/Course3/Lab4/validations.py index b18de65a2e..0633389b78 100644 --- a/Course3/Lab4/validations.py +++ b/Course3/Lab4/validations.py @@ -18,7 +18,12 @@ 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): + 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