-1

https://i.stack.imgur.com/MDNRm.png

def GetJumpFunc(search):
    path = GetPathByName(search[1])
    lines = ReadAllLines(path)
    for x in range(0, len(lines)):
        if ( search[0] in lines[x] and lines[x+3].find("jump") != -1):
            return GetStringBetwean2Chars(lines[x+4], "L", "")
    return ''

def GetPathByName(name):
    return ".\Transformice-0\{0}.class.asasm".format(name.replace("\\x", "%"))

def ReadAllLines(path):
    return ReadAllText(path).split('\n')

Help me? I get error in line 2:

path = GetPathByName(search[1])
IndexError : String index out of range

Mahir Islam
  • 1,941
  • 2
  • 12
  • 33
SnapKWI
  • 5
  • 5
  • Please specify what value are you passing to GetJumpFunc(). Maybe that value does not have the element at index 1. – Sanchit Kumar Nov 11 '18 at 06:47
  • It says that `search` does not have second value in it. what is in the `search`? – Mehrdad Pedramfar Nov 11 '18 at 06:47
  • I give all code : https://pastebin.com/m071QqwD – SnapKWI Nov 11 '18 at 07:45
  • Please read "How to create a [mcve]". Then use the [edit] link to improve your question (do not add more information via comments). Otherwise we are not able to answer your question and help you. Linking to external sites, or pictures is really **not** what you should do. – GhostCat Nov 19 '18 at 14:13

1 Answers1

0

The search[1] assumes that the string search is filled with a string with at least 2 chars.

Try this to quit on an empty string.

def GetJumpFunc(search):
    if not search:
        return ''
    path = GetPathByName(search[1])

or just quit on this error:

def GetJumpFunc(search):
    try:
        path = GetPathByName(search[1])
    except IndexError:
        return ''
576i
  • 7,579
  • 12
  • 55
  • 92