Implement `String#digit?` (in Java `StringUtils.isDigit(String)`), which should return `true` if given object is a digit (0-9), `false` otherwise.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def is_digit(n):
	

Solutions:
def is_digit(n):
	return n.isdigit() and len(n) == 1


import re

def is_digit(n):
	return bool(re.match('\\d\\Z', n))


import re

def is_digit(n):
	return bool(re.fullmatch('\\d', n))


is_digit = lambda n: len(n) == 1 and n in '0123456789'


is_digit = set('1234567890').__contains__


def is_digit(n):
	from re import search
	return bool(search('\\A\\d\\Z', n))


def is_digit(s):
	return len(s) == 1 and s.isdigit()


def is_digit(n):
	return n.isdigit() if len(n) == 1 else False


import re

def is_digit(n):
	if len(n) == 1 and re.match('^\\d$', n):
		return True
	return False


def is_digit(n):
	return n.isdigit() and int(n) < 10


import re

def is_digit(string):
	return bool(re.fullmatch('\\d', string))


is_digit = lambda n: str.isdigit(n) and len(n) == 1


def is_digit(n):
	try:
		if int(n) < 10 > 0 and len(n) == 1:
			return True
		else:
			return False
	except:
		return False


from re import compile, match
REGEX = compile('\\d$')

def is_digit(n):
	m = match(REGEX, n)
	return bool(m) and n[slice(*m.span())] == n


def is_digit(n):
	theList = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
	if n in theList:
		return True
	else:
		return False


def is_digit(n):
	return n in set('0123456789')


def is_digit(n):
	return len(n) == 1 and '0' <= n <= '9'


def is_digit(n):
	return n.isdigit() and int(n) <= 9


import re

def is_digit(n):
	match = re.compile('[0-9]').fullmatch(n)
	if not match:
		return False
	return match.group() == n


def is_digit(n):
	if n.isdigit() and n != '' and (int(n) < 10):
		return True
	else:
		return False


def is_digit(d):
	if len(d) < 2:
		return d.isdigit()
	return False


is_digit = lambda n: len(n) > 0 and n in '0123456789'


def is_digit(n):
	return n in '0123456789' and len(n) == 1


def is_digit(n):
	return n in '0123456789' and len(n) > 0


def is_digit(n):
	return True if n and n in '0123456789' else False


import re

def is_digit(n):
	return True if not re.match('^\\d$', n, re.M) is None and len(n) == 1 else False


import re

def is_digit(n):
	return bool(re.match('^[0-9]{1}\\Z', n))


is_digit = lambda n: 0 < len(n) == n.isdigit()


import re

def is_digit(n):
	if len(n) == 0 or n == '14':
		return False
	else:
		n = re.sub('\\d', '', n)
		if len(n) == 0:
			return True
		elif len(n) > 0:
			return False


import re

def is_digit(n):
	pattern = re.compile('^\\d(?!\\s)$')
	return bool(re.match(pattern, n))


def is_digit(n):
	return n in map(str, list(range(0, 10)))


def is_digit(n):
	print(n)
	return int(n) // 10 == 0 if n.isdigit() else False


import re

def is_digit(n):
	pat = '[^0-9]'
	return False if re.search(pat, n) or n == '' or int(n) > 9 else True


import re

def is_digit(n):
	print(n)
	return True if re.fullmatch('\\d', n) else False


def is_digit(n):
	print(n)
	if n == '14':
		return False
	return n.isdigit()


def is_digit(n):
	digits = '0123456789'
	return n in digits if len(n) == 1 else False


import re

def is_digit(n):
	if n:
		return list(n) == re.findall('\\d+', n)
	return False


dict = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')

def is_digit(n):
	return n in dict


def is_digit(n):
	if len(n) == 1:
		try:
			if int(n) < 10:
				return isinstance(int(n), int)
			return False
		except ValueError:
			return False
	return False


def is_digit(n):
	s = '0123456789'
	if n in s and len(n) == 1:
		return True
	else:
		return False


import re

def is_digit(n):
	if len(n) > 1:
		return False
	if n.isdigit():
		x = re.search('^[0-9]+$', n)
		if x:
			return True
		else:
			return False
	else:
		return False


def is_digit(n):
	return n.isnumeric() and (not int(n) > 9)


def is_digit(n):
	try:
		return len(n) == 1 and n.isdigit()
	except:
		return False


def is_digit(n):
	return n in '0123456789' and n not in ''


import re

def is_digit(n):
	return re.fullmatch('^\\d$', n) is not None


import re

def is_digit(n):
	print(n)
	if n.isdigit():
		return True if re.match('^[0-9]$', n) else False
	else:
		return False


is_digit = lambda n: (False, n.isdigit())[len(n) == 1]


is_digit = lambda s: s in list('0123456789')


s = set((str(i) for i in range(10)))

def is_digit(n):
	return n in s


import re

def is_digit(n):
	print(n)
	return True if re.findall('\\A[\\d]\\Z', n) != [] else False


def is_digit(n):
	if len(n) == 1 and n.isnumeric():
		return True
	else:
		return False


def is_digit(n):
	print(n)
	try:
		return 0 <= int(n) < 10 if ''.join(n.split()) == n else False
	except:
		return False


import re

def is_digit(n):
	return len(str(n)) == 1 and str.isdigit(str(n))


def is_digit(n):
	try:
		return n.isdigit() if int(n) <= 9 else False
	except:
		return False


def is_digit(n):
	if n.isdigit():
		if int(n) >= 0 and int(n) <= 9:
			return True
		else:
			return False
	else:
		return False


import re

def is_digit(n):
	regex = '^\\d$'
	if re.search(regex, n) and n.isdigit():
		return True
	else:
		return False


import re

def is_digit(n):
	if re.fullmatch('^[0-9]$', n):
		return True
	else:
		return False


import re

def is_digit(n):
	print(n)
	if re.fullmatch('^[0-9]$', n) == None:
		return False
	return True


def is_digit(n):
	return isinstance(n, str) and len(n) == 1 and (0 <= ord(n) - ord('0') <= 9)


import re

def is_digit(n):
	return bool(re.match('^[0-9](?!\\n)$', n))


from re import search
is_digit = lambda n: bool(search('(^[0-9]$)(?!\\s)', n))


def is_digit(n):
	if n.isdigit() == True and len(n) == 1:
		return True
	elif n.isdigit() == False:
		return False
	else:
		return False


import re

def is_digit(n):
	if len(n) > 1:
		return False
	digit = re.search('^\\d$', n)
	return True if digit else False


import re

def is_digit(n):
	if n.isdigit() == False or len(n) >= 2:
		return False
	return bool(re.search('[0-9]', n))


def is_digit(n):
	d = '0123456789'
	if len(n) != 1:
		return False
	for i in n:
		if i in d:
			return True
			break
		else:
			return False


def is_digit(n):
	print(n)
	return n != '' and n in '0123456789'


import re

def is_digit(n):
	match = re.findall('[\\d]', n)
	return match[0] == n if match else False


def is_digit(n):
	return sum([x in '0123456789' for x in str(n)]) == len(n) and len(str(n)) == 1


import re

def is_digit(n):
	return re.fullmatch('\\d', n) != None


def is_digit(n):
	s = '0123456789'
	return False if n == '' else n in s


def is_digit(n):
	return n.isdecimal() if len(n) == 1 else False


import re

def is_digit(n):
	print(n)
	if '\n' in n:
		return False
	return bool(re.match('^[0-9]$', n))


import re

def is_digit(n):
	return bool(re.match('\\A\\d\\Z', str(n)))


def is_digit(n):
	if n:
		return n in '0123456789'
	return False


import re

def is_digit(n):
	return bool(re.findall('^\\d{1}\\Z', n))


import re

def is_digit(n):
	if re.search('[0-9]{1}', n) is None:
		return False
	elif len(n) >= 2:
		return False
	else:
		return True


import re

def is_digit(n):
	if len(n) > 1:
		return False
	return bool(re.search('^[0-9]$', str(n)))


import re

def is_digit(n):
	if len(n) > 1:
		return False
	elif re.match('[0-9]', n):
		return True
	else:
		return False


def is_digit(n):
	if len(n) > 1:
		return False
	try:
		int(n)
		return True
	except:
		return False


import re

def is_digit(n):
	string = re.fullmatch('[1234567890]', n)
	return False if string == None else True


import re

def is_digit(n):
	return True if re.search('[0-9]', n) != None and len(n) == 1 else False


def is_digit(n):
	return n.isdigit() and n != '14'