-1
我正在嘗試爲基於文本的冒險遊戲創建一個非常基本的戰鬥功能,我的問題是我特別減輕了關於這條線的錯誤。Python - 不能分配給函數調用?
random.choice(gold_dropped)+ =金
有問題的錯誤是語法錯誤:無法分配給函數調用錯誤,我難倒是什麼原因造成的問題,以及如何解決它。
任何反饋都將不勝感激。
在該錯誤所在的功能如下所示。
高清戰鬥():
enemy_health = (random.choice(random_enemy_Health))
enemy_attack = (random.choice(random_enemy_Attack))
print("You are fighting a" ,random.choice(enemies), "with an attack amount of" ,enemy_attack, "and a health amount of" ,enemy_health,".")
while (enemy_health > 0):
enemy_attack - health;
while (health > 0):
attack - enemy_health;
if enemy_health == 0:
print("The enemy has been defeated!")
random.choice(gold_dropped) += gold
if health == 0:
print("You have been defeated! Return back to the Hub and re-prepare yourself!")
hub_travel()
你可能是指'黃金+ = random.choice(gold_dropped)'。 – jasonharper