I am trying to convert one type of data into another with this script, but I have to go through it character-by-character so many lists are involved. I have to change the type of conversion halfway through, so it gets kind of funky. Around halfway through, it throws the IndexError: list index out of range
at me. Here's what is going wrong:
def split(word):
return [char for char in word]
def conversion(contents):
one=len(contents)/int(2)
if ".5" in str(one):
one=one-float(.5)
contents=split(contents)
for i in range(len(contents)):
if i == one:
print("*************BROKEN*************")
break
current='{}'.format(ord(contents[i]))
for r in current:
print(current)
#conversion
contents.remove(contents[i])
for i in range(len(contents)):
current='{}'.format(ord(contents[i])) ##The offending line
for r in current:
print(current)
#other conversion
contents.remove(contents[i])