所以我是新来的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