第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

訪問函數(shù)外部的參數(shù)和變量 (Python)

訪問函數(shù)外部的參數(shù)和變量 (Python)

達(dá)令說 2021-06-06 16:39:09
import timedef classBase(class_name, class_health, class_damage, class_hit_chance):    print("You are a " + class_name + "!")def enemyBase(enemy_name, enemy_health, enemy_damage, enemy_hit_chance, enemy_alive):    time.sleep(2)    print("Out of nowhere, a " + enemy_name + " appears!")    enemy_total_health = enemy_healthprint("Welcome to Blades of Goblonia!")user_name = input("What is your name?")type(user_name)print("Hello, " + user_name + "!")user_class_choice = input("""What class would you like to be?A) WarriorB) HunterC) Wizard""")if user_class_choice == "A" :    user_class = classBase("Warrior", 50, 7, 95)elif user_class_choice == "B" :    user_class = classBase("Hunter", 40, 10, 85)elif user_class_choice == "C" :    user_class = classBase("Wizard", 35, 12, 80)enemyBase("Goblin", 30, 10 , 60, True)time.sleep(1)user_action_choice = input("""Would you like to    A) Hit    B) Run    C) Heal""")if user_action_choice == "A" :    print("Hit")elif user_action_choice == "B" :    print("Run")elif user_action_choice == "C" :    print("Heal")在我的游戲代碼中,我試圖訪問和更改敵人的健康狀況,因?yàn)樗鼤谖抑匦聞?chuàng)建時發(fā)生變化。為了創(chuàng)建一個傷害、效果,我需要改變敵人的總健康值,但我不能引用這個變量。我將如何編寫代碼才能訪問局部變量和參數(shù)?謝謝 :)
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 220 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號