所以我是新來的python,我正在製作一個文本基礎遊戲。我創建了一個庫存清單,如果玩家不止一次拿起物品,第二次應該能夠發出消息說他們已經擁有這個物品。我認爲它在某種程度上可以在某種程度上不超過一個值,但不會打印該消息。請幫忙!!基於文本的遊戲庫存列表(Python)
elif decision == "use H on comb":
global inventory
if inventory.count("comb")>1:
print ("You already got this item.")
print ("")
print ("Inventory: " + str(inventory))
if inventory.count("comb")<1:
print ("(pick up comb)")
print ("You went over to the table and picked up the comb,")
print ("it's been added to your inventory.")
add_to_inventory("comb")
print("")
print ("Inventory: " + str(inventory))
game()
謝謝你了!現在這太簡單了哇 – John