Having Trouble with level Bookkeper


#1

My Code:

defeated = 0
while True:
enemies = self.findEnemies()
nearest_enemy = self.findNearest(enemies)
if enemies and nearest_enemy:
self.attack(nearest_enemy)
if nearest_enemy and nearest_enemy.health <=0:
defeated=defeated+1
if self.now() > 15:
self.moveXY(59, 33)
self.say( defeated )
break
while True:
items = self.findItems()
nearest_item = self.findNearest(items)
if nearest_item:
self.move(nearest_item)
if self.now()>30:
self.moveXY(58, 33)
self.say(self.gold)
defeated=0
break
My

while True:
enemies = self.findEnemies()
nearest_enemy = self.findNearest(enemies)
if enemies and nearest:
self.attack(nearest_enemy)
if nearest and nearest.health <=0:
defeated=defeated+1
if self.now() > 45:
self.moveXY(59, 33)
self.say( defeated )
break


#2

I cant read your code make sure you use ``` when writing your code

code

#3

check the faq when posting your code.
the </> button on the toolbar helps :slight_smile: