当我运行以下代码时:
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:\Computing\A453 Assessment\Task 3\main.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()
不能将其作为参数。它可能是两者,因为您要将调用的结果print
分配给每一个。你知道吗也许它确实提到了“力量差异”,但由于你没有提供细节,我无法对此作出回应。你知道吗
相关问题 更多 >
编程相关推荐