I’m new to CodeCombat. Decided to try and learn a new skill for New Years and this is my first attempt at programming. I’m stuck trying to figure out why my hero isn’t saying a total when hero moves to the X by the mage. Here is my code:
while True:
traps = hero.findHazards("fire-traps")
lowestTrap = 0
trapIndex = 0
while trapIndex < len(traps):
trap = traps[trapIndex]
trapIndex += 1
if trap.value > lowestTrap:
lowestTrap = trap.value
traps = hero.findHazards("fire-traps")
highestTrap = 9999
trapIndex = 0
while trapIndex < len(traps):
trap = traps[trapIndex]
trapIndex += 1
if trap.value < highestTrap:
highestTrap = trap.value
hero.moveXY(27, 42)
hero.say(lowestTrap.value + highestTrap.value)
break
What am I missing? Also, I put trapIndex += 1 in this code because I’ve been using enemyIndex +=1 or friendIndex +=1 on previous levels, but I’m not really sure what it does, just that it needs to be there for the code to work. Thank,
Twisted