python check indexerror list index out of range