我知道有类似的线索,我只是很难理解。在
我一直收到一个错误消息,说“Lvl”未定义为变量。我假设这是因为我需要将一个变量从initstatswarrior()传递给selectclass()。但是,我不确定,因为我已经多年没有使用Python了。如有任何提示,我们将不胜感激。在
Traceback (most recent call last):
File "C:\Program Files\Notepad++\rpg\start.py", line 48, in <module>
selectclass()
File "C:\Program Files\Notepad++\rpg\start.py", line 17, in selectclass
Level 1 """, Lvl, """
NameError: name 'Lvl' is not defined
import os
def cls():
os.system ("CLS")
def namecharacter():
cls()
playername = input("Character Name: ")
print ("You shall be called", playername, "in the realm.\n")
input("Press Enter to continue...")
def selectclass():
cls()
print("""Here are your current stats:
-----------------
Level 1 """, Lvl, """
-----------------
Hit Points: """, HP, """
Skill Points: """, SP, """
Armor: """, AC, """
-----------------
Attack: """, Atk, """
Accuracy: """, Acc, """
Mind: """, Mind, """
Evade: """, Evade, """
Defense: """, Def, """
Charisma: """, Cha, """
-----------------
""")
input("Press Enter to continue...")
def initstatswarrior():
HP = 100
SP = 40
AC = 60
Atk = 11
Acc = 11
Mind = 8
Evade = 8
Def = 13
Cha = 9
namecharacter()
initstatswarrior()
selectclass()
谢谢你!在
你还没有给Lvl赋值,所以你得到了一个错误。你可以这样做:
输出:
^{pr2}$相关问题 更多 >
编程相关推荐