Given a string and an array of integers representing indices, capitalize all letters at the given indices. 

For example:

* `capitalize("abcdef",[1,2,5]) = "aBCdeF"`
* `capitalize("abcdef",[1,2,5,100]) = "aBCdeF"`. There is no index 100.

The input will be a lowercase string with no spaces and an array of digits.

Good luck!

Be sure to also try: 

[Alternate capitalization](https://www.codewars.com/kata/59cfc000aeb2844d16000075)

[String array revisal](https://www.codewars.com/kata/59f08f89a5e129c543000069)

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def capitalize(s,ind):
	

Solutions:
def capitalize(s, ind):
	ind = set(ind)
	return ''.join((c.upper() if i in ind else c for (i, c) in enumerate(s)))


def capitalize(s, ind):
	result = list(s)
	for index in ind:
		try:
			result[index] = result[index].upper()
		except IndexError:
			break
	return ''.join(result)


def capitalize(s, ind):
	return ''.join((char.upper() if i in ind else char for (i, char) in enumerate(s)))


def capitalize(s, ind):
	return ''.join((letter.upper() if index in ind else letter for (index, letter) in enumerate(s)))


def capitalize(s, ind):
	for i in ind:
		s = s[:i] + s[i:].capitalize()
	return s


def capitalize(s, ind):
	for i in ind:
		try:
			s = s[:i] + s[i].upper() + s[i + 1:]
		except:
			return s
	return s


def capitalize(s, ind):
	return ''.join([s[x].capitalize() if x in ind else s[x] for x in range(len(s))])


def capitalize(s, ind):
	l = list(s)
	for v in ind:
		if len(l) >= v:
			l[v] = l[v].upper()
	return ''.join(l)


def capitalize(s, ind):
	list_s = list(s)
	cap = []
	for i in range(len(list_s)):
		if i in ind:
			list_s[i] = list_s[i].upper()
		cap.append(list_s[i])
	cap_s = ''.join(cap)
	return cap_s


def capitalize(s, ind):
	res = ''
	for (key, letter) in enumerate(s):
		if key in ind:
			res += letter.upper()
		else:
			res += letter
	return res


def capitalize(s, ind):
	return ''.join(([c, c.upper()][i in ind] for (i, c) in enumerate(s)))


capitalize = lambda s, a: ''.join(((x, x.upper())[y in a] for (y, x) in enumerate(s)))


def capitalize(s, ind):
	char_list = [char.upper() if idx in ind else char for (idx, char) in enumerate(s)]
	return ''.join(char_list)


def capitalize(s, ind):
	return ''.join([s[i].upper() if i in ind else s[i] for i in range(len(s))])


def capitalize(s, ind):
	s = list(s)
	for i in ind:
		if i < len(s):
			s[i] = s[i].upper()
		else:
			continue
	return ''.join(s)


def capitalize(s, ind):
	out = ''
	for i in range(len(s)):
		if i in ind:
			out = out + s[i].capitalize()
		else:
			out = out + s[i]
	return out


def capitalize(s, ind):
	new_word = ''
	for (idx, val) in enumerate(s):
		if idx in ind:
			new_word += val.upper()
		else:
			new_word += val
	return new_word


def capitalize(s, ind):
	s1 = [i for i in s]
	for indeks in range(0, len(s)):
		if indeks in ind:
			s1[indeks] = s1[indeks].upper()
	return ''.join(s1)


def capitalize(s, ind):
	res = ''
	for (i, v) in enumerate(s):
		if i in ind:
			res += v.upper()
		else:
			res += v.lower()
	return res


def capitalize(s, arr):
	s = list(s)
	for i in arr:
		try:
			s[i] = s[i].upper()
		except IndexError:
			continue
	return ''.join(s)


def capitalize(s, ind):
	(ret, ixd) = ('', ind[:])
	ch = ixd.pop(0)
	for (i, e) in enumerate(s):
		if i == ch:
			ret += e.upper()
			if ixd:
				ch = ixd.pop(0)
		else:
			ret += e
	return ret


def capitalize(s, ind):
	return ''.join([x.upper() if i in ind else x.lower() for (i, x) in enumerate(s)])


def capitalize(s, ind):
	s = [*s]
	for n in ind:
		if not n > len(s):
			s[n] = s[n].upper()
	return ''.join(s)


def capitalize(s, ind):
	t = ''
	for (num, x) in enumerate(s):
		if num in ind:
			t += x.upper()
		else:
			t += x
	return t


def capitalize(s, ind):
	for i in ind:
		if i < len(s):
			s = s[:i] + s[i].upper() + s[i + 1:]
	return s


def capitalize(s, ind):
	arr = list(s)
	for i in range(len(s)):
		if i in ind:
			arr[i] = arr[i].upper()
	return ''.join(arr)


def capitalize(s, ind):
	liste = []
	for letter in s:
		liste.append(letter)
	i = 0
	for i in range(0, len(liste)):
		if i in ind:
			liste[i] = liste[i].capitalize()
	string = ''.join([str(i) for i in liste])
	return string


def capitalize(s, ind):
	res = []
	for (i, v) in enumerate(s):
		if i in ind:
			res.append(v.upper())
		else:
			res.append(v)
	return ''.join(res)


def capitalize(s, ind):
	if not s:
		return 'aBCdeF'
	s = list(s)
	for index in ind:
		if index > len(s) - 1:
			continue
		cap = ord(s[index]) - 32
		s[index] = chr(cap)
	return ''.join(s)


def capitalize(s, ind):
	new_string = ''
	for letter in range(len(s)):
		if letter in ind:
			new_string += s[letter].upper()
		else:
			new_string += s[letter]
	return new_string


def capitalize(x, a):
	b = []
	for (i, e) in enumerate(x):
		if i in a:
			b += e.upper()
		else:
			b += e
	return ''.join(b)


def capitalize(s, ind):
	new_s = ''
	for (i, c) in enumerate(s):
		if i in ind:
			new_s = new_s + c.upper()
		else:
			new_s = new_s + c
	return new_s


def capitalize(s, ind):
	t = [str(i) for i in s]
	a = ''
	for x in range(0, len(t)):
		if x in ind:
			t[x] = t[x].upper()
		a += t[x]
	return a


def capitalize(s, ind):
	if ind == []:
		return s
	else:
		return capitalize(s[:ind[0]] + s[ind[0]:].capitalize(), ind[1:])


def capitalize(s, ind):
	temp = list(s)
	for i in ind:
		if i > len(temp):
			return ''.join(temp)
		temp[i] = temp[i].upper()
	return ''.join(temp)


def capitalize(s, ind):
	res = ''
	a = 0
	for i in s:
		if a in ind:
			res += i.upper()
		else:
			res += i
		a += 1
	return res


def capitalize(s, ind):
	c = ''
	for i in range(len(s)):
		k = 0
		for j in range(len(ind)):
			if i == ind[j]:
				c += s[i].upper()
				k += 1
			else:
				continue
		if k == 0:
			c += s[i]
	return c


def capitalize(s, ind):
	count = 0
	output = []
	for i in s:
		if ind.count(count) > 0:
			output.append(i.upper())
			count += 1
		else:
			output.append(i)
			count += 1
	return ''.join(output)


def capitalize(s, ind):
	new_list = []
	for (i, letter) in enumerate(s):
		if i in ind:
			new_list.append(letter.upper())
		else:
			new_list.append(letter)
	return ''.join(new_list)


def capitalize(s, ind):
	ar = list(s)
	for (index, value) in enumerate(ar):
		for i in ind:
			if i == index:
				ar[index] = value.upper()
	return ''.join(ar)


def capitalize(s, ind):
	s = list(s)
	last_indx = len(s) - 1
	for indx in ind:
		if indx > last_indx or indx < 0:
			pass
		else:
			s[indx] = s[indx].upper()
	return ''.join(s)


def capitalize(s, ind):
	s = list(s)
	for element in ind:
		if element <= len(s):
			s[element] = s[element].upper()
	return ''.join(s)


def capitalize(s, ind):
	new_string = ''
	i = 0
	while i < len(s):
		if i in ind:
			new_string += s[i].upper()
		else:
			new_string += s[i]
		i += 1
	return new_string


def capitalize(s, ind):
	how_about_a_list = list(s)
	for number in ind:
		if number <= len(s):
			how_about_a_list[number] = how_about_a_list[number].upper()
	return ''.join(how_about_a_list)


def capitalize(s, ind):
	for i in ind:
		if i >= len(s):
			break
		s = s[:i] + s[i].capitalize() + s[i + 1:]
	return s


def capitalize(s, ind):
	sy = list(s)
	for i in ind:
		try:
			sy[i] = sy[i].upper()
		except IndexError:
			print('Index out of range')
	return ''.join(sy)


def capitalize(s, ind):
	letters = list(s)
	for i in ind:
		if i >= len(letters):
			break
		letters[i] = letters[i].upper()
	return ''.join(letters)


def capitalize(s, ind):
	return ''.join(list([i[1].upper() if i[0] in ind else i[1] for i in enumerate(s)]))


def capitalize(s, ind):
	ret = ''
	for (i, letter) in enumerate(s):
		if i in ind:
			ret += letter.upper()
		else:
			ret += letter
	return ret


def capitalize(s, ind):
	tulos = ''
	for i in range(0, len(s)):
		merkki = s[i]
		if i in ind:
			merkki = merkki.upper()
		tulos += merkki
	return tulos


def capitalize(s, ind):
	split_s = list(s)
	for i in ind:
		try:
			split_s[i] = split_s[i].upper()
		except IndexError:
			pass
	return ''.join(split_s)


def capitalize(s, ind):
	sl = len(s)
	ls = []
	st = ''
	for i in s:
		ls.append(i)
	for i in range(sl):
		if i in ind:
			ls[i] = ls[i].upper()
	for i in ls:
		st += i
	return st


def capitalize(chars, indices):
	indices.sort()
	result_list = []
	next_index_to_cap = 0
	for (index, char) in enumerate(chars):
		if next_index_to_cap < len(indices) and index == indices[next_index_to_cap]:
			char = char.capitalize()
			next_index_to_cap += 1
		result_list.append(char)
	return ''.join(result_list)


def capitalize(chars, indices):
	for index in indices:
		if index < len(chars):
			chars = chars[0:index] + chars[index].capitalize() + chars[index + 1:]
	return chars


def capitalize(s, ind):
	newstring = []
	for numero in range(len(s)):
		if numero not in ind:
			newstring.append(s[numero])
		elif numero in range(len(s)):
			newstring.append(s[numero].capitalize())
	return ''.join(newstring)


def capitalize(s, ind):
	s = list(s)
	ind_new = []
	for k in ind:
		if k < len(s):
			ind_new.append(k)
	for i in range(0, len(ind_new)):
		s[ind_new[i]] = s[ind_new[i]].upper()
		i += 1
	return ''.join(s)


def capitalize(s, ind):
	j = list(s)
	for i in ind:
		if i < len(s) + 1:
			j[i] = j[i].upper()
	return ''.join(j)


def capitalize(s, ind):
	res = ''
	for (n, i) in enumerate(s):
		if n in ind:
			res += i.swapcase()
		else:
			res += i
	return res


def capitalize(s, ind):
	s = list(s)
	for e in ind:
		try:
			s[e] = s[e].capitalize()
		except:
			continue
	return ''.join(s)


def capitalize(s, ind):
	arr = []
	for (i, el) in enumerate(s):
		if i in ind:
			arr.append(el.upper())
		else:
			arr.append(el)
	return ''.join(arr)


def capitalize(s, ind):
	new = list(s)
	for i in ind:
		if i > len(s):
			pass
		else:
			new[i] = new[i].upper()
	return ''.join(new)


def capitalize(s, ind):
	st = ''
	for (index, value) in enumerate(s):
		if index in ind:
			st += s[index].upper()
		else:
			st += s[index]
	return st


def capitalize(s, ind):
	str_lst = [letter for letter in s]
	for index in ind:
		try:
			str_lst[index] = str_lst[index].upper()
		except:
			pass
	return ''.join(str_lst)


def capitalize(s, ind):
	s_list = [ch for ch in s]
	for i in ind:
		try:
			s_list[i] = s_list[i].upper()
		except IndexError:
			pass
	return ''.join(s_list)