python check if list index in range