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:
how changing:
for in range(len(raw_list)): into:
for in range(len(raw_list)-1): 
Comments
Post a Comment