index = [0, 2, 5]
s = "I am like stackoverflow-python"
for i in index:
s = s[i].upper()
print(s)
IndexError: string index out of range
I understand that in the first iteration the string, s
, become just the first character, an uppercase "I" in this particular case. But, I have tried to do it without the "s = " , using swapchcase()
instead, but it's not working.
Basically, I'm trying to print the s
string with the index letters as uppercase using Python 3.X