Based on an element found in a list, I'd like to update the index value in my for loop. I believe I've done this, but my Python script doesn't seem to be outputting the correct values and I cannot figure out why:
My list looks like this:
dataXY = [['6', 'c', '3', '7', '2', '9', '1', '7'],['8', '4', 'c', '7', '9', '3', '4', '7', '1', '2']]
And my code that works on this is:
for lists in dataXY:
XYbezier = []
final_lists = []
for datum in range(len(lists)):
if lists[datum] == 'c':
for k in range(-1,4):
if k != 0:
XYbezier.append(lists[datum+k])
else:
if lists[datum-1] == 'c':
datum += 3
if datum != len(lists):
final_lists.append(lists[datum])
else:
final_lists.append(lists[datum])
print datum
What it's printing is this: 1 5 3 4 5 6 7 0 1 2 6 4 5 6 7 8 9
For some reason, the index value is being reset, but then restored (from how it skips to 5 from 1 and then goes back to 3) I don't understand why it's doing this, and I need the index value to jump 3 places and permanently update instead of restoring itself back to its original value.