首页 > 解决方案 > randint 不想与 int 相乘,然后从 int 中减去

问题描述

您好,我是 python 3.x 的初学者,出于某种原因,我的 randint 不想像以前那样工作。我有一个分数,应该减去 1 到 5 之间的随机数乘以你的攻击值。这以前可以正常工作,但现在当我尝试这样做时:

while php > 0:
    doing = input(print('What will', starter, 'do? '))
    if doing == 'attack':
        php -= randint(1,5) * atk
        hp -= randint(1,5) * patk

这曾经工作得很好,但现在它说:

 line 61, in <module>
    hp -= randint(1,5) * patk
TypeError: unsupported operand type(s) for -=: 'function' and 'int'

我不知道该怎么办。可能是因为函数与 int(hp) 共享名称吗?

标签: python-3.x

解决方案


推荐阅读