如何克服“ IndexError类型异常”的错误?

时间:2019-11-12 19:53:19

标签: python-3.x index-error

我必须为特定输入获得特定输出,如下所示:

code: soMe SuPPLies liKE Ice-cREAm aRe iMPORtant oNly tO THeir cReaTORS. tO DestroY thEm iS pOInTLess.
says: destroy their ice-cream supplies

我在下面编写了一个程序:

line = input("code: ")
words = line.split()
human = words[11] + ' ' + words[8] + ' ' + words[3] + ' ' + words[1]
print('says:',human.lower())

当我得到所需的输出时,编译器给我一个错误-'您的提交引发了IndexError类型的异常。这发生在您提交的第3行。'

请帮助我。

0 个答案:

没有答案