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)

Difficulty: introductory

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  # assumes the indexes are sorted
    return ''.join(result)


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

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):
    return ''.join(j.upper() if i in ind else j for i, j in enumerate(s))

def capitalize(s,ind):
    return "".join([j.upper() if i in ind else j for i,j in enumerate(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):
    result = ""

    for index, letter in enumerate(s):

        if index in ind:
            result += letter.upper()

        else:
            result += letter

    return result

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 element in list
        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):
    # Iterate over every character 'char' of string 's'.
    # Capitalize the char if its position 'idx' is present
    # in list 'ind'.
    # If it is not, just return the char.
    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):
    return "".join(x.upper() if i in ind else x for i, x in enumerate(s))


def capitalize(s,ind):
    return ''.join([m.upper() if i in ind else m for i, m in enumerate(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,ind):
    arr = []
    for i in range(len(s)):
        if i in ind:
            arr.append(s[i].upper())
        else:
            arr.append(s[i])
    return "".join(arr)

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):
    ind = set(ind)
    return ''.join(c if i not in ind else c.upper() for i,c in enumerate(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):
    return ''.join(s[x] if x not in ind else s[x].swapcase() for x in range(len(s)))
        


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

def capitalize(s, ind):
    return ''.join(s[x] if x not in ind else s[x].upper() for x in range(len(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):
    return ''.join(letter.upper() if i in ind else letter for i, letter in enumerate(s))

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


def capitalize(s,ind): # jai shree ram!!!!
    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(s,ind):
    return ''.join([i.upper() if loop in ind else i for loop, i in enumerate(s)])

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):
    return ''.join([s[i].upper() if i in ind and i<len(s) else s[i] for i in range(len(s)) ])




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):
#     string = [s[ind] for letter in s if letter]
    result = []
    for i, char in enumerate(s):
        if i in ind:
            result.append(char.upper())
        else:
            result.append(char)
    return ''.join(result)

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

def capitalize(s,ind):
    s = list(s)
    return ''.join([s[i].upper() if i in ind else s[i] for i in range(0,len(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):
    a=""
    for i,c in enumerate(s):
        if i in ind:
            a=a+c.upper()
        else:
            a=a+c
    return a    

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

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

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):
    ind = set(ind)
    return ''.join(l.upper() if i in ind else l for i, l in enumerate(s))

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

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

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):
    arr = list(s)
    for i in ind:
        if i <= len(arr):
            arr[i] = arr[i].upper()
    return ''.join(arr)

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):
    a = ""
    for i in range(len(s)):
        if i in ind:
            a = a + s[i].upper()
        else:
            a += s[i]
    return a

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):
    new_string = ''
    for i in range(len(s)):
        if i in ind:
            new_string += s[i].upper()
        else:
            new_string += s[i]
    return new_string

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):
    out = ""
    s = list(s)
    for i in ind:
        if i < len(s):
            s[i] = s[i].upper()
    return "".join(s)

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):
    for i in ind:
        if i > len(s):
            continue
        else:
            s = s[:i] + s[i].upper() + s[i+1:]

    return s 

#You can do it!
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):
    output = ''
    for i in range(len(s)):
        if i in ind:
            if i < len(s):
                output += s[i].upper()
        else:
            output += s[i] 
    return output

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):
    a=''
    for i in range(len(s)):
        if i in ind:
            a+=s[i].upper()
        else:
            a+=s[i]
    return a

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,letter in enumerate(s):
        if i in ind :
            arr.append(letter.upper())
        else:
            arr.append(letter)
    return "".join(arr)

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):
    n = ""
    for i in range(len(s)):
        if i in ind:
            n += s[i].upper()
        else:
            n += s[i]
    return n

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


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):
    return ''.join(s[i].upper() if i < len(s) and i in ind else s[i] for i in range(len(s)))

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

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)