当我运行以下代码时:
while start == "yes":
player1name = input("Player 1 what shall your character be called?")
player2name = input("Player 2 what shall your character be called?")
player1strength=print("Player 1,your strength score is :)", random.randint(1,7))
player2strength=print("Player 2,your strength score is :)", random.randint(1,7))
strengthdifference =(int(player1strength) - int(player2strength))
if strengthdifference<0:
strengthdifference=player2strength-player1strength
strengthdifference=strengthdifference/5
player1skill=int(input("Player 1,enter your skill score :)"))
player2skill=int(input("Player 2,enter your skill score :)"))
skilldifference=player1skill-player2skill
我得到了这个追溯:
File "C:ComputingA453 AssessmentTask 3main.py", line 18, in <module>
strengthdifference =(int(player1strength) - int(player2strength))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
我在做什么错?如何解决错误?
错误说他们的 player1strength
或 player2strength
(或可能两者)是 None
, int()
不能将其作为参数。这可能是 is 兼有,因为您将调用print
的结果分配给每个。
也许 it 确实说了一些关于 *强度差异的信息,但是由于您没有提供细节,我无法对此做出回应。