Define a method ```hello``` that ```returns``` "Hello, Name!" to a given ```name```, or says Hello, World! if name is not given (or passed as an empty String).

Assuming that ```name``` is a ```String``` and it checks for user typos to return a name with a first capital letter (Xxxx).

Examples:

Difficulty: EASY
Tags: Fundamentals

Starter code:
def hello(name=''):
	

Solutions:
def hello(name=''):
	return f"Hello, {name.title() or 'World'}!"


def hello(name=''):
	return f"Hello, {(name.capitalize() if name else 'World')}!"


def hello(name=None):
	if not name:
		return 'Hello, World!'
	return 'Hello, %s!' % name.capitalize()


def hello(name=''):
	return 'Hello, {}!'.format(name.title() if name else 'World')


hello = lambda name='': 'Hello, {}!'.format('World' if not name else name.capitalize())


def hello(name=''):
	return 'Hello, %s!' % ['World', name.title()][name != '']


def hello(name='World'):
	return 'Hello, {}!'.format(name.capitalize() if name else 'World')


def hello(name=''):
	return f"hello, {name or 'world'}!".title()


def hello(name=''):
	return 'Hello, ' + (name.capitalize() or 'World') + '!'


def hello(name=''):
	return 'Hello, ' + name.title() + '!' if len(name) > 1 else 'Hello, World!'


def hello(name=''):
	return f"Hello, {(name or 'world').capitalize()}!"


hello = lambda n='': f"Hello, {n.title() or 'World'}!"


def hello(*name):
	if name:
		if name[0]:
			return 'Hello, ' + name[0].title() + '!'
		else:
			return 'Hello, World!'
	else:
		return 'Hello, World!'


def hello(name=''):
	if name:
		return f'Hello, {name[0].capitalize() + name[1:].lower()}!'
	else:
		return 'Hello, World!'


def hello(name=None):
	name = name.capitalize() if name else 'World'
	return 'Hello, %s!' % name


def hello(name='World'):
	if not name:
		name = 'World'
	return f'Hello, {name.title()}!'


from typing import Optional

def hello(*args) -> str:
	if args and len(args[0]):
		name = args[0]
	else:
		name = 'world'
	return 'Hello, {}!'.format(name.title())


def hello(*name):
	if len(name) > 0:
		return 'Hello, ' + name[0].lower().capitalize() + '!' if len(name[0]) > 0 else 'Hello, World!'
	return 'Hello, World!'


def hello(name=''):
	if name != '':
		return 'Hello, ' + name.capitalize() + '!'
	return 'Hello, World!'


import string

def hello(name='World'):
	if name == '':
		return 'Hello, World!'
	else:
		return 'Hello, ' + name.capitalize() + '!'


def hello(name=None):
	try:
		test = name + str(name)
		print('No Error')
	except:
		name = ''
		print('Error Handled!!!')
	if name == '' or name == None:
		new_name = 'World'
	else:
		new_name = ''
		letter = 0
		for i in name:
			if letter == 0 and i.islower:
				new_name += i.upper()
			elif letter == 0:
				new_name += i
			elif letter > 0 and i.isupper:
				new_name += i.lower()
			else:
				new_name += i
			letter += 1
	return 'Hello, ' + new_name + '!'


hello = lambda n='', d='World': 'Hello, %s!' % (n or d).title()


def hello(name=None):
	ans = ''
	if name is '' or name is None:
		return 'Hello, World!'
	nm = list(name)
	for i in range(0, len(nm)):
		if i == 0:
			ans += nm[i].upper()
		else:
			ans += nm[i].lower()
	return 'Hello, ' + ans + '!'


def hello(name='World'):
	return 'Hello, %s!' % (name + int(not bool(name)) * 'World').capitalize()


def hello(name=''):
	name = str(name)
	if name == 'None' or len(name) == 0 or name == ' ' * len(name):
		return 'Hello, World!'
	else:
		return f'Hello, {name.title()}!'


def hello(name=''):
	if not name:
		return 'Hello, World!'
	return f'Hello, {name[0].upper()}{name[1:].lower()}!'


def hello(name=None):
	return 'Hello, World!' if name in ['', None] else 'Hello, {}!'.format(name.capitalize())


def hello(name='World'):
	if name == '':
		name = 'World'
	toLower = lambda x: x.lower() if len(x) > 0 else ''
	return 'Hello, ' + name[0].upper() + toLower(name[1:]) + '!'


def hello(*args):
	try:
		name = str(args[0])
		return 'Hello, ' + name[0].upper() + name[1:].lower() + '!'
	except:
		return 'Hello, World!'


def hello(name=''):
	return 'Hello, World!' if name is None or name == '' else f'Hello, {name.capitalize()}!'


def hello(name=''):
	return 'Hello, World!' if len(name) <= 0 else 'Hello, ' + name.lower().title() + '!'


def hello(name='World'):
	if name == '':
		return 'Hello, World!'
	return 'Hello, {}!'.format(name[:1].upper() + name[1:].lower())


def hello(name=None):
	if name:
		capName = name.capitalize()
		if capName:
			return 'Hello, {}!'.format(capName)
		else:
			return 'Hello, World!'
	else:
		return 'Hello, World!'


def hello(name='world'):
	if name == '':
		name = 'world'
	return 'Hello, {}!'.format(name.title())


def hello(name=''):
	if not name or name == '':
		return 'Hello, World!'
	elif name:
		name = name.lower()
		return f'Hello, {name.title()}!'


def hello(name=''):
	if len(name) == 0:
		name = 'World'
	return 'Hello, ' + str(name.lower()).capitalize() + '!'


def hello(name='') -> str:
	return f'Hello, {name.title()}!' if name else 'Hello, World!'


def hello(name=''):
	name = name.lower()
	name = name.title()
	if name != '':
		return f'Hello, {name}!'
	else:
		return f'Hello, World!'


def hello(name=0):
	if not name:
		return 'Hello, World!'
	else:
		return 'Hello, ' + name.capitalize() + '!'


def hello(name='World'):
	if not name:
		return 'Hello, World!'
	else:
		return 'Hello, ' + name.capitalize() + '!'
hello()
hello('John')
hello('aLIce')
hello('')
hello('')


def hello(name='World'):
	if name == '' or name == 'World':
		return 'Hello, World!'
	output = name.lower()
	output = output.split()
	output2 = output[len(output) - 1]
	return 'Hello, ' + output2.capitalize() + '!'


def hello(name=None):
	if name:
		a = name.lower()
		b = a.capitalize()
		return f'Hello, {b}!'
	elif not name:
		return 'Hello, World!'


def hello(name=''):
	if len(name) == 0:
		return 'Hello, World!'
	ls = list(name)
	word = True
	for i in range(len(ls)):
		word = word and ls[i].isalpha()
	if word == True:
		return 'Hello, ' + name[0].upper() + name[1:].lower() + '!'


def hello(name='World'):
	if name:
		return f'Hello, {name.lower().capitalize()}!'
	return 'Hello, World!'


def hello(name=''):
	if len(name.strip()) == 0:
		return 'Hello, World!'
	else:
		a = name.title()
		return 'Hello, ' + a + '!'


def hello(name=None):
	if name is None or len(name) == 0:
		return 'Hello, World!'
	name = name.capitalize()
	return f'Hello, {name}!'


def hello(name='World'):
	return 'Hello, %s!' % (name.lower().capitalize() if name != '' else 'World')


def hello(name=False):
	if name:
		return 'Hello, ' + name.capitalize() + '!'
	else:
		return 'Hello, World!'


def hello(name=None):
	if name == '' or name == None:
		return 'Hello, World!'
	else:
		name = name.lower()
		name = name.capitalize()
		return 'Hello, ' + name + '!'


def hello(*name):
	if name == ():
		return 'Hello, World!'
	elif name[0] == '':
		return 'Hello, World!'
	else:
		return 'Hello, ' + name[0].lower().capitalize() + '!'


def hello(name='World'):
	if name == '':
		return 'Hello, World!'
	else:
		name = name.capitalize()
		return 'Hello, %s!' % name
print(hello('John'))
print(hello('aLIce'))
print(hello())
print(hello(''))


def hello(name='World'):
	if not name:
		name = 'World'
	return 'Hello, ' + name.lower().capitalize() + '!'


def hello(name='World'):
	if name == '':
		name = 'World'
	name = list(name.lower())
	name[0] = name[0].upper()
	return 'Hello, {}!'.format(''.join(name))


def hello(name=''):
	if name == '' or name == None:
		return 'Hello, World!'
	else:
		name1 = name.lower()
		name2 = name1.capitalize()
		return f'Hello, {name2}!'


def hello(name=0):
	if name == '' or name == 0:
		return 'Hello, World!'
	else:
		name = name.lower()
		name = name.capitalize()
		return 'Hello, ' + name + '!'


def hello(name=None):
	if name == None:
		return 'Hello, World!'
	elif name == '':
		return 'Hello, World!'
	else:
		name = name.capitalize()
		return 'Hello, ' + name + '!'


def hello(name=None):
	if name == None or len(name) < 1:
		return 'Hello, World!'
	return f'Hello, {name.capitalize()}!'


import unittest

def hello(name=None):
	return 'Hello, {}!'.format(name.capitalize() if name else 'World')

class TestHello(unittest.TestCase):

	def test_hello_should_return_default_string_with_not_given_name(self):
		self.assertEqual(hello(None), 'Hello, World!')

	def test_hello_should_return_default_string_with_given_name_is_empty_string(self):
		self.assertEqual(hello(''), 'Hello, World!')

	def test_hello_with_only_lower_case(self):
		self.assertEqual(hello('abcde'), 'Hello, Abcde!')

	def test_hello_with_mixed(self):
		self.assertEqual(hello('aBcDe'), 'Hello, Abcde!')


import unittest
HELLO = 'Hello'
WORLD = 'World'
EXCLAMATION_MARK = '!'
DEFAULT_TEMPLATE = '{}, {}{}'

def hello(name=None):

	def get_hello(word, hello_string=HELLO, exclamation_mark=EXCLAMATION_MARK):
		return DEFAULT_TEMPLATE.format(hello_string, word, exclamation_mark)
	return get_hello(word=name.title()) if name else get_hello(word=WORLD)

class TestHello(unittest.TestCase):

	def test_hello_should_return_default_string_with_not_given_name(self):
		self.assertEqual(hello(None), 'Hello, World!')

	def test_hello_should_return_default_string_with_given_name_is_empty_string(self):
		self.assertEqual(hello(''), 'Hello, World!')

	def test_hello_with_only_lower_case(self):
		self.assertEqual(hello('abcde'), 'Hello, Abcde!')

	def test_hello_with_mixed(self):
		self.assertEqual(hello('aBcDe'), 'Hello, Abcde!')


def hello(name=''):
	if name == '' or type(name) != str:
		return 'Hello, World!'
	else:
		final_name = name[0].upper() + name[1:].lower()
		return 'Hello, ' + final_name + '!'


def hello(name=None):
	if name is None:
		return 'Hello, World!'
	elif name == '':
		return 'Hello, World!'
	else:
		lower_name = name.lower()
		cap_name = lower_name.capitalize()
		return 'Hello, ' + cap_name + '!'


def hello(name='World'):
	if len(name) < 1:
		name = 'World'
	return f'Hello, {name.title()}!'


def hello(name=''):
	if name == '':
		return 'Hello, World!'
	else:
		name = name = ''.join((w[0].upper() + w[1:].lower() for w in name.split()))
		return f'Hello, {name}!'


def hello(name='World'):
	if len(name) == 0:
		return 'Hello, World!'
	retval = ''
	for i in range(len(name)):
		if i == 0:
			retval += name[i].upper()
		else:
			retval += name[i].lower()
	return f'Hello, {retval}!'


def hello(name=''):
	return 'Hello, {}'.format(name[0].upper() + name[1:].lower() + '!') if len(name) > 0 else 'Hello, World!'


def hello(name=''):
	return 'Hello, {}!'.format((name or 'World').title())


hello = lambda n='World': 'Hello, %s!' % (n.capitalize() if n != '' else 'World')


def hello(name='World'):
	if name == '':
		name = 'World'
	return 'Hello, {}!'.format(name.lower().capitalize())


def hello(name=''):
	if name != '':
		name = name.capitalize()
		return 'Hello, %s!' % name
	else:
		return 'Hello, World!'
	pass


def hello(name='World'):
	if name in ('', ' '):
		name = 'World'
	return f'Hello, {name.title()}!'


def hello(name=''):
	if name == '':
		txt = 'Hello, World!'
		return txt
	elif len(name) == 1:
		naam = name.upper()
		txt = f'Hello, {naam}!'
	elif len(name) > 1:
		naam = name[0].upper() + name[1:].lower()
		txt = f'Hello, {naam}!'
	else:
		txt = 'Hello, World!'
		return txt
	return txt


def hello(name=''):
	if name != '':
		return 'Hello, ' + name.lower().title() + '!'
	return 'Hello, World!'