[英]How to stop a random item from being printed out letter for letter
我的游戲中有一個隨機項目丟棄系統的問題。
這是我的代碼:
import random
#Potato heals +5
potato = "Potato"
apple = 1
apple_name = "apple"
#is_damage_2
rusted_sword = "Rusted shortsword"
#Worth $80 - 10 can make Goldblade
gold_ingot = "Gold ingot"
#Worth $120
sapphire = "Sapphire"
random_drop = [sapphire,potato,gold_ingot,rusted_sword]
inventory = [apple_name, apple,]
rand_item = random.choice(random_drop)
inventory += rand_item
print(inventory)
當它打印庫存時...隨機項目被添加,但它拼寫出來的字母是這樣的:P,o,t,a,t,o。
我想把它拼寫成:“馬鈴薯”
我只學習了幾個星期的Python並且非常困惑。 任何幫助將不勝感激!
使用append()方法,如下所示:
inventory.append(rand_item)
請參閱這些關於+=
對迭代的內容的答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.