if语句的语法无效

sbb*_*bb0 2 python syntax if-statement python-3.x

我将粘贴整个函数,因为它不长:

def decideTile():
    global tile
    global exp
    global maxexp

    tile += 1
    exp += math.ceil(random.randrange(math.ceil((maxexp/2)/2,maxexp/2))

    if exp >= maxexp:
       levelUp()
    else:
       tileChoices = ['Battle','Loot','Nothing']
       fileType = random.choice(tileChoices)

    if tileType == 'Battle':
        battle()
    elif tileType == 'Loot':
        loot()
    elif tileType == 'Nothing':
        nothing()
Run Code Online (Sandbox Code Playgroud)

现在,Python正在说

if exp >= maxexp:
Run Code Online (Sandbox Code Playgroud)

它的一部分是'无效语法',我不完全确定原因.感谢帮助!

jco*_*ado 10

前一行中缺少一个括号.要解决此问题,只需在该行的末尾添加一个右括号,如下所示:

exp += math.ceil(random.randrange(math.ceil((maxexp/2)/2,maxexp/2)))
Run Code Online (Sandbox Code Playgroud)