Your coworker was supposed to write a simple helper function to capitalize a string (that contains a single word) before they went on vacation.

Unfortunately, they have now left and the code they gave you doesn't work. Fix the helper function they wrote so that it works as intended (i.e. make the first character in the string "word" upper case).

Don't worry about numbers, special characters, or non-string types being passed to the function. The string lengths will be from 1 character up to 10 characters, but will never be empty.

Difficulty: EASY
Tags: String algorithms

Starter code:
def capitalize_word(word):
	

Solutions:
def capitalize_word(word):
	return word.capitalize()


def capitalize_word(word):
	return ''.join((char.capitalize() for char in word.split()))


def capitalize_word(word):
	return str.capitalize(word)


def capitalize_word(word):
	first = word[0].upper()
	remaining = word[1:].lower()
	text = first + remaining
	return text


def capitalize_word(word):
	a = word.lower()
	b = a.capitalize()
	return b


def capitalize_word(word):
	return ''.join(word.capitalize())


def capitalize_word(word):
	return ''.join(word[0].upper() + word[1:])


def capitalize_word(word):
	capLetter = ''.join((char.capitalize() for char in word[0]))
	capOthers = ''.join((char.lower() for char in word[1:10]))
	capWord = capLetter + capOthers
	return str(capWord)


def capitalize_word(word):
	word = word.lower()
	word = word.title()
	return word


def capitalize_word(word):
	return word.title()
print(capitalize_word('word'))


def capitalize_word(word):
	return word.title()


def capitalize_word(word):
	ans = ''.join((char.lower() for char in word))
	return ans.capitalize()


def capitalize_word(word):
	for char in word:
		len(word) > 1 and len(word) < 10
	return word.capitalize()
print(capitalize_word('blea'))


def capitalize_word(w):
	for char in w[0]:
		return ''.join(char.title()) + w[1:]


def capitalize_word(word):
	final = ''
	pos = 0
	while pos < len(word):
		if pos == 0:
			final += word[pos].upper()
		else:
			final += word[pos]
		pos += 1
	return final


def capitalize_word(word):
	for char in word:
		return word.title()


def capitalize_word(word):
	word_2 = ''
	for i in range(len(word)):
		if i == 0:
			word_2 += word[i].upper()
		else:
			word_2 += word[i]
	return word_2


def capitalize_word(word):
	char = [char.upper() for char in word]
	return ''.join(char[0] + word[1:])


def capitalize_word(word):
	newword = ''
	x = 0
	for n in word:
		if x == 0:
			newword += word[0].upper()
			x += 1
		else:
			newword += n
	return newword


def capitalize_word(word):
	if len(word) >= 2:
		return word[0].upper() + word[1:]
	else:
		return word.upper()


def capitalize_word(word):
	str = ''
	lst = list()
	for i in word:
		lst.append(i)
	lst[0] = lst[0].upper()
	for i in lst:
		str += i
	return str


def capitalize_word(word):
	ls = list(word)
	ls[0] = ls[0].upper()
	return ''.join(ls)


def capitalize_word(word):
	firstLetter = word[0:1]
	restWord = word[1:]
	firstLetter = firstLetter.upper()
	return firstLetter + restWord


def capitalize_word(word):
	return word[0].upper() + word[1:len(word)].lower()


def capitalize_word(w):
	return w[0].upper() + w[1:].lower()


capitalize_word = lambda s: s.capitalize()


def capitalize_word(word):
	return capitalize(word)

def capitalize(word):
	s = ''
	for i in range(len(word)):
		if i == 0:
			s += word[i].upper()
		else:
			s += word[i].lower()
	return s


def capitalize_word(word):
	x = word[0].upper()
	return x + word[1:]


def capitalize_word(word):
	words = word.capitalize()
	return words


def capitalize_word(word):
	flit = list(word.lower())
	flit[0] = flit[0].upper()
	return ''.join(flit)


def capitalize_word(word):
	letter = word
	return letter.title()


def capitalize_word(word):
	ans = word.capitalize()
	return ans


def capitalize_word(word):
	for i in word:
		if word[0].lower():
			return word[0].upper() + word[1:]


def capitalize_word(word):
	word = word.lower()
	x = word.capitalize()
	return x


def capitalize_word(word=''):
	return f'{word.title()}'


def capitalize_word(word):
	char = 0
	while char < len(word):
		if char == 0:
			word2 = word[char].upper()
		else:
			word2 = word2 + word[char]
		char = char + 1
	return word2


def capitalize_word(word):
	if len(word) == 1:
		return word.upper()
	return word[0].upper() + word[1:]


def capitalize_word(word):
	return word.upper().title()


capitalize_word = lambda n: n.title()


def capitalize_word(word):
	return word.upper().capitalize()


import string

def capitalize_word(word):
	return f'{string.capwords(word)}'


def capitalize_word(word):
	res = []
	res[:] = word
	print(res)
	newarry = []
	for i in range(0, len(res)):
		print(res[i])
		if res[i] == res[0]:
			newarry.append(res[0].upper())
		else:
			newarry.append(res[i])
	print(''.join(newarry))
	answer = ''.join(newarry)
	return answer


def capitalize_word(word):
	return word.capitalize()
capitalize_word('hi')


def capitalize_word(word):
	return ''.join((char.upper() if idx == 0 else char for (idx, char) in enumerate(word)))


def capitalize_word(word):
	init = word[0]
	rem = word[1:len(word)]
	return ''.join([init.upper(), rem])


def capitalize_word(word):
	if len(word) == 1:
		return ''.join((char.upper() for char in word))
	else:
		return word[0].upper() + word[1:]


def capitalize_word(word):
	if word == word.lower():
		return word.capitalize()


def capitalize_word(word):
	s = word[0].upper()
	word = s + word[1:]
	return word


def capitalize_word(word):
	arr = []
	for i in range(len(word)):
		if i == 0:
			arr.append(word[0].upper())
		else:
			arr.append(word[i])
	return ''.join(arr)


def capitalize_word(word):
	trueword = list(word)
	s = trueword[0]
	trueword[0] = s.upper()
	return ''.join(trueword)


def capitalize_word(word):
	return str(''.join((char.capitalize() for char in word))).title()


def capitalize_word(word):
	word = word.replace(word[0], word[0].upper(), 1)
	return word


def capitalize_word(word):
	first_symbol = word[0].upper()
	return first_symbol + word[1:]


def capitalize_word(word):
	return ' '.join((word[:1].upper() + word[1:] for word in word.split(' ')))
print(capitalize_word('hello'))


def capitalize_word(word):
	return '{}'.format(word.capitalize())


def capitalize_word(word):
	all_lower = word.lower()
	capitalize = all_lower.capitalize()
	return capitalize


def capitalize_word(word):
	new = word.lower()
	return new[0].upper() + new[1:]


def capitalize_word(word):
	a = word[0].upper()
	b = slice(1, len(word))
	y = word[b]
	return a + y


def capitalize_word(word):
	print(word)
	return ''.join((char.upper() if word.index(char) == 0 else char for char in word))


def capitalize_word(word):
	return word.capitalize()
print(capitalize_word('word'))