Code Coach: More Metacharacters (Python - RegEx) - Solution is incomplete
Hi, since there is no button to report incorrect solutions in CodeCoach, I will post this as a topic of discussion. In short: The regular expression r"\w*[A-Z]\w*[0-9]\w*" given in the model solution does not fit if the user decides to create a password where the number precedes the capital letter, e.g. "jskjf2klsjdDlk". You can use my playground code to see for yourself: https://www.sololearn.com/compiler-playground/ceKj74ci8AAX --------------------------------------------------------------------------------- Here is the task description: (copied) More Metacharacters Let's imagine we are creating our own authentication system. Create a program that takes a password as input and returns "Password created" if - it has at least one uppercase character - it has at least one number The Program should output "Wrong format" if requirements above are not met. Sample Input Hal44gb8 Sample Output Password created -------------------------------------------------------------------------------- This is the given solution (Excuse me, if there are any typos, I could not copy it) import re password = input() pattern = r"\w*[A-Z]\w*[0-9]\w*" if re.match(pattern, password): print("Password created") else: print("Wrong format")