Why does it show IndexError: string index out of range