L
L
Loyxim2020-07-25 10:12:02
Python
Loyxim, 2020-07-25 10:12:02

An IndexError occurs, what should I do?

There is an error "Index error: list index out of range" in the line text = event.text.split(' '), how to fix it?

Code link: https://pastebin.com/n5CCMZGn

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alekssamos, 2020-07-25
@alekssamos

If only one word is sent in the message, such as "Start", there is only one element in the text sheet, text[0]. Accordingly, drive all commands under try. Or even as an option, immediately after split do And then there will definitely be two elements [0] and [1]. text.append(" ")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question