我试图生成随机的句子,但它不工作,我已经导入随机的,这是我所:随机功能将无法正常工作
if "razor blade" in inventory:
sentences = ("What do you take yourself for?","Are you insane?", "You are not doing that.", "You have to be joking.", "This isn't going to work.")
num= random.randrange (0,5)
print (sentences[num])
elif "razor blade" not in inventory:
print ("you don't own this item in your inventory.")
你会得到什么错误? – jacg
在这种情况下,您可以使用'else:'而不是'elif',您当前的代码应该可以工作 –
我没有收到错误消息,它只是重复“您为自己做了什么?每一次 – John