This is because str[0:1] uses slicing while str[0] uses indexing. Slicing never raises an error when the index is out range but indexing does raise an error. When you run str[0], the error raised is an IndexError, because it is an issue caused by the indexing.