【发布时间】:2019-11-29 21:12:35
【问题描述】:
我一直在尝试为我的学校项目建立一个健康系统,但无论 Monster_health 不在循环中,我的朋友和我似乎都无法解决这个问题。
代码:
monster_health = 100
while monster_health > 0:
playeraction = input('Placeholder beast wants to fight you!!\n1) Basic Attack')
print(monster_health)
if playeraction == 1:
monster_health = monster_health-7
continue
if monster_health <= 0:
print('You killed the monster!! Gain nothing, this is a test you barbarian')
break
输出:
Placeholder beast wants to fight you!!
1) Basic Attack
100 #should print 97 but fails to
【问题讨论】:
-
请编辑问题以包含实际输出和预期输出。
标签: loops python-3.7 integer-arithmetic