Python random.randint()发行

2024-05-17 04:02:11 发布

您现在位置:Python中文网/ 问答频道 /正文

随机生成一个数字后,我检查用户的输入是否匹配。如果是,打印一行,如果不是,打印另一行。即使用户猜对了,另一行也会打印出来。

chosenNumber = input ("Choose a number: ")
int (chosenNumber)
diceRoll = random.randint (1,3)
print ("The number rolled is: ",diceRoll)
if diceRoll == chosenNumber:
      print ("WINNER")
else:
      print ("LOSER")

谢谢你的帮助。


Tags: the用户numberinputis检查用户数字random