I’m having a bug with a bot to do operations on IQ Option

Asked

Viewed 246 times

-3

He can sometimes make the entrees, but always at the end of that mistake, and I don’t know how to fix

Erro:
Traceback (most recent call last):
  File "main.py", line 267, in <module>
    par = x.split(';')[1].upper()
IndexError: list index out of range

api creator website: https://github.com/viniciuscbb/bot-sinais

  • The error message is clear, could put in the question the code fragment that generates this error, so we can offer you an accurate answer.

1 answer

1

You are getting this error by trying to access an index in an array that does not exist.

One way to try to solve is by checking the size of the array after splitting by value ;

arrpar = x.split(';')
par = ""
if len(arrpar) >= 2:
    par = arrpar[1].upper()

I’m checking if the value is >= to two, because the first index of the array is zero (python uses indexed arrays with zero index). Since we want the index value 1 we must check if the vector (array) has the size greater than or equal to 2.

Also check that now the value of your variable par will be "" (empty string), in case there is no array with more than 2 positions.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.