我試圖生成隨機的句子,但它不工作,我已經導入隨機的,這是我所:隨機功能將無法正常工作
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