我一直在研究一个小型战斗模拟程序,其中包含伤害、健康、防御和其他东西(只是为了好玩),但我遇到了这个“语法错误”。语法错误是由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))