python - For loop with embedded if statement list index out of range -


i have following python code:

raw_list = reminders_context['data']['reminder_list'] 

this statement works fine , gets required info want.

the following code gives me error list index out of range inner workings of loop eg.[i substitute 'i' value number, first 10 characters of list item [:10]], work fine when set trace in pdb mode.

raw_list[i]['created'][:10] == raw_list[i + 1]['created'][:10] 

code gives error:

for in range(len(raw_list)):     if raw_list[i]['created'][:10] == raw_list[i + 1]['created'][:10]:         del raw_list[i + 1]     else:         pass 

how can change not error?

i have seen how list gets reduced in loop when iterating not know how implement in code.

the article i'm referring here:

python : list index out of range error

how changing:

for in range(len(raw_list)): 

into:

for in range(len(raw_list)-1): 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -