import random
import time
def header():
printNow("The program is starting now, prepare to be slain")
monsterTest();
def monsterTest():
for i in range(0,1):
currentHp = 99;
printNow("Starting Health is: "+str(currentHp))
randomHit = random.randint(0,50)
attack1 = currentHp - randomHit
printNow("Monster attacks for: "+str(randomHit))
printNow("Remaining Health is: "+str(currentHp-randomHit))
battle1 = attack1
printNow(">>>")
printNow("Next Attack Incoming!")
printNow(">>>")
time.sleep(1.5)
currentHp = battle1
printNow("Current Health is: "+str(currentHp))
attack2 = currentHp - randomHit
printNow("Monster attacks again for: "+str(attack2))
battle2 = currentHp - attack2
printNow("After That we are left with "+str(battle2)+" HP")
footer();
def footer():
printNow(">>>")
printNow("Thank you for using Cidadel's Battle Simulator, this concludes our test...")
printNow(header())
The program is starting now, prepare to be slain
Starting Health is: 99
Monster attacks for: 38
Remaining Health is: 61
>>>
Next Attack Incoming!
>>>
Current Health is: 61
Monster attacks again for: 23
After that we are left with 38 HP
>>>
Thank you for using Citadel's Battle Simulator, this concludes our test...
*None*
>>>
为什么我没有这个,我认为它与我的printNow命令有关,但我不确定我做错了导致实际的无值..:/
我试图正常运行它,但我一直得到None值,因为我在列表中注释掉了我的行
答案 0 :(得分:2)
当你这样做时:
printNow(header())
header()
的结果会传递给printNow
,因为header()
会返回None
,显然会打印return None
,因为最后隐含header
每个功能。
只需拨打header()
:
{{1}}