0

我一直在研究一个小型战斗模拟程序,其中包含伤害、健康、防御和其他东西(只是为了好玩),但我遇到了这个“语法错误”。语法错误是由enemystr = str(enemydamage) 引起的。我尝试删除它,但它只是说下面的打印语句是语法错误。

def enemyattack():
    enemyrandompick = random.randint(1, 4)
    if enemyrandompick == 1:
        enemydamage = (random.randint(1, 3) * (enemyattack - (defense * 1.25))
        enemystr = str(enemydamage)
        print "The enemy's attack hits you and takes away " + enemystr , "health, leaving you with" + str(int(health))
4

2 回答 2

2

此行有一个不匹配的括号:

enemydamage = (random.randint(1, 3) * (enemyattack - (defense * 1.25)))
#                                                                     ^ Missing closing paranthesis
于 2013-10-18T02:28:27.170 回答
-1

而且我认为您也没有声明变量“健康”。

`print "敌人的攻击击中你并带走" +enemystr , "health, leave you with" + str(int(health))
                                                                                                         ^
`
于 2013-10-18T07:09:26.437 回答