python check if index in list exists