Write a simple regex to validate a username. Allowed characters are:

- lowercase letters,
- numbers,
- underscore

Length should be between 4 and 16 characters (both included).

Difficulty: EASY
Starter code: def validate_usr(username):
	

Solutions:
import re

def validate_usr(un):
	return re.match('^[a-z0-9_]{4,16}$', un) != None


import re

def validate_usr(username):
	return bool(re.match('^[a-z0-9_]{4,16}$', username))


import re
validate_usr = lambda str: bool(re.match('^[a-z\\d_]{4,16}$', str))


import re

def validate_usr(username):
	return re.match('^[a-z0-9_]{4,16}$', username) is not None


def validate_usr(username):
	if len(username) < 4 or len(username) > 16:
		return False
	allowed = 'abcdefghijklmnopqrstuvwxyz0123456789_'
	for i in username:
		if i not in allowed:
			return False
	return True


def validate_usr(username):
	numeric = '0123456789'
	if len(username) >= 4 and len(username) <= 16:
		for letter in username:
			status = 0
			if letter.islower() or letter == '_':
				status = 1
			for num in numeric:
				if letter == num:
					status = 1
			if status == 0:
				return False
		return True
	else:
		return False


import re

def validate_usr(username):
	if re.match('^[a-z0-9_]{4,16}$', username):
		return True
	else:
		return False


def validate_usr(user):
	return 3 < len(user) < 17 and all((c in 'abcdefghijklmnopqrstuvwxyz_0123456789' for c in user))


from re import fullmatch

def validate_usr(username):
	return bool(fullmatch('[_0-9a-z]{4,16}', username))