Implement `String#whitespace?(str)` (Ruby), `String.prototype.whitespace(str)` (JavaScript), `String::whitespace(str)` (CoffeeScript), or `whitespace(str)` (Python), which should return `true/True` if given object consists exclusively of zero or more whitespace characters, `false/False` otherwise.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def whitespace(string):
	

Solutions:
def whitespace(string):
	return not string or string.isspace()


def whitespace(string):
	return not string.lstrip()


def whitespace(string):
	return string.strip() == ''


def whitespace(string):
	return string.strip('\n\t\r ') == ''


whitespace = lambda x: not x.strip()


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

def whitespace(string):
	return bool(match(REGEX, string))


import re

def whitespace(st):
	return len(re.findall('\\s', st)) == len(st)


def whitespace(str):
	return bool(str.isspace() or not str)


def whitespace(string):
	return True if not string else string.isspace()


whitespace = lambda s: not s or s.isspace()