小编coo*_*man的帖子

Python随机程序无法解决

我在我的Raspberry Pi上做了一个基本的随机程序,它有点像这样.

import random
print ("Welcome to the PC Expo's new game, PC Dispenser, what will you win?")
WinorLose = random.randint(1, 1000)
if WinorLose <100:
    print ("You won a Nintendo Wii.")
elif WinorLose >200:
    print ("You won a Sony PSP.")
elif WinorLose > 300:
    print ("You won a Nintendo Wii U.")
elif WinorLose > 400:
    print ("You won a Sony PS Vita.")
else:
    print ("Not your lucky day, Try again.")

print ("Thank you for the visit.")
Run Code Online (Sandbox Code Playgroud)

如果你不知道它做了什么,它有机会给你一个虚拟的PSP,Wii U等等.但它所做的只是打印"你赢得索尼PSP",或"不是你的幸运日,再试一次".怎么了?任何修复?

python random if-statement fall-through

3
推荐指数
1
解决办法
38
查看次数

标签 统计

fall-through ×1

if-statement ×1

python ×1

random ×1