python check if list index is in range