List index out of range


#1

i=0
while i<len(text_list):
    if (text_list[i]=="!" and text_list[i+1].islower()) :                
    	del text_list[i]     
    i += 1

I am a beginner programmer. I don't understand why i get the "List index out of range" error.


#2

Where is your test_list?


#3

This is a part of the program. It's not the whole program.


#4

del removes a specific index hence your index got messed up. Which is why there's the error.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.