为什么这句话不会返回90?
orc = raw_input("Does the orc attack or miss?")#Replacing with a random number thing later
health = 100
takeahit = 0
def damage(orc):
if orc == "hit":
return takeahit == 10 # Ive tried plus as well im having similar problems with choices in inventory
elif orc == "miss":
print "The Orc misses"
healthtwo = health - takeahit
print healthtwo
答案 0 :(得分:1)
以适当的方式从函数返回:
gatsby-browser.js
您需要调用定义的函数。 在函数定义
之后添加它def damage(orc):
print(orc)
if orc == "hit":
takeahit = 10 #MODIFIED
elif orc == "miss":
takeahit=0
print "The Orc misses"
return takeahit #ADDED STATEMENT