我是Python的新手,无法正常使用库存系统。我不知道为什么每当我运行此代码时,列表中的[2]索引都会更新,但是我各项的功能都无法正常工作。
我已经删除了数千条命令,以便您可以更轻松地了解这里发生的事情。
Player = [raw_input("Welcome, please sign your first name here: "), raw_input("Now your last name here: "), "temp"]
def intro():
print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
print "Very well then " + Player[0]
print " "
print "I just have to check a few things really quick though."
print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
if Player[0].isalpha() and Player[1].isalpha():
print "And. It appears that everything is in order."
print " "
print "Sorry for the hold up, you wouldn't believe the amount of pranksters we get here, wasting our time."
print" "
print "But anyways, everything appears to be in order, so. See you again soon"
print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
else:
build_choice(raw_input("A Sword, a Staff, and a Bow. Which of these weapons do you take?"))
def build_choice(wpn):
if wpn == "Sword" or "sword":
Player[2] = wpn
swordwpn()
elif wpn == "Staff" or "staff":
Player[2] = wpn
staffwpn()
elif wpn == "Bow" or "bow":
Player[2] = wpn
bowwpn()
else:
print "You look for a ''" + wpn + "'' in the chest but don't find one."
print "It looks like you have to go with one of the items in the chest already"
build_choice(raw_input("A Staff, and a Bow. Which of these weapons do you take?"))
def swordwpn():
print "sword"
def staffwpn():
print "staff"
def bowwpn():
print "bow"
intro()
print Player[2]
无论您实际键入哪种武器,它都会不断打印“剑”。
A Sword, a Staff, and a Bow. Which of these weapons do you take? *staff*
sword
调试软件没有发现任何代码错误,而且我无法弄清楚问题出在哪里。
它可能很容易捕获,但是再次,难以置信 python的新手