我正在尝试编写一个简单的脚本,该脚本将给出 1 到 100 之间的随机数,并根据结果打印出“你赢了”或“你输了”。当测试特定数字时,== 1它工作正常,但是当用它替换它时,<=会出现以下错误:TypeError: '<' not supported between instances of 'NoneType' and 'int'
这是我的代码:
import random
number = print(random.randint(1, 100))
if number <= 20:
print("you win")
else:
print("you lose")
Run Code Online (Sandbox Code Playgroud) python ×1