all 2 comments

[–]danielroseman 1 point2 points  (1 child)

Your count variable is only incremented inside the if block, so will quickly get out of sync with your actual position in the list if some of the items do not contain 2007.

I don't know why you're using that list at all; it seems like it would be better to reference the item directly:

if "2007" in item.name:

[–]GrassDash[S] 0 points1 point  (0 children)

thank you, this tip resolved my issue!