#234 · Regular expressions · Beginner · 30 XP · about 5 min
A sign-up form accepts a username only when it follows these rules:
Write is_valid_username(name) that returns True if name follows every rule and False if it breaks any of them.
is_valid_username('alice_99') # returns True is_valid_username('9lives') # returns False is_valid_username('al') # returns False is_valid_username('jo-jo') # returns False
The second name starts with a digit, the third is too short, and the last one contains a dash.
Any other character makes the name invalid, including spaces, accented letters such as é, and a line break at the end.
First solves only, ranked by stars and then time.