I do not remember for sure, but I think get_item_count returns the amount of items within the list starting at 1 instead of 0. Programming languages (and computers in general) usually start at 0 programmatically, so when iterating you have to start counting from 0 instead of 1.
I have not tested it, but something like this should fix the issue:
var item_count = _item_list.get_item_count()
for i in item_count - 1:
if _item_list.get_item_text(i) == my_text_key:
_item_list.remove_item(i)
Another issue that could be causing the problem, if the issue is not get_item_count counting starting at 1, is that you are modifying the array/list as you are iterating over it. If the code above does not fix the issue, then you will need to store the item(s) you plan to remove separate from the for loop.
Again, I have not tested, but something like this should work:
var item_count = _item_list.get_item_count()
# store all of the indexes that we need to delete
var items_to_remove = []
# you might need to remove the "-1" below if it is not causing the issue
for i in item_count - 1:
if _item_list.get_item_text(i) == my_text_key:
items_to_remove.append(i)
# remove all of the items marked
for index in items_to_remove:
_item_list.remove_item(i)
# Thinking about it, you might need to delete/remove items at
# the highest index first, so the order does not change.
# The following code should do that, I think.
#while items_to_remove.empty() == false:
# var _item_to_remove = items_to_remove.pop_back()
# _item_list.remove_item(_item_to_remove)
Hopefully this helps! If none of the code works, let me know and I can see if I can replicate the issue (and hopefully find a solution) in a test project.