Infinitely adds the index of the item to the jan_1_index list. I'm not sure why, as the if statement should only be iterated through once, because it's not a while statement. Is it do with the code being in a function, or is it something else?

Edit: When I print the list out, it outputs:

[0]
[0, 0]
[0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0, 0]

and so on.

Double edit: I produced a small section of code with everything necessary.

Two issues with the code - list.index will always return the index of the first match - so effectively, you'll get repeated indices. The other issue (which is hard to tell from your code) is that likely something is mutating appointment_dates...