2017-05-11 6 views
-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() 
+4

'金+ = random.choice':

は、あなたは、単に(命令の妥当性以下のpython 3.5で確認)中間変数を使用する必要があります。 – jasonharper

答えて

0

命令random.choice(gold_dropped)+ =金で、あなたは変数の値を追加し、 "金"(それがなければなりません:

デフ戦闘()既存の変数であれば、関数の匿名の結果に何かを割り当てることはできません)。そのため、Pythonインタプリタが不平を言うのです。 (gold_dropped)

あなたはおそらく意味
if enemy_health == 0: 
    print("The enemy has been defeated!") 
    choice_of_gold_dropped = random.choice(gold_dropped) + gold 
... 
関連する問題