# Use your new skill to choose what to do: hero.time
while True:
# If it's the first 10 seconds, attack.
if hero.time < 10:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
pass
# Else, if it's the first 35 seconds, collect coins.
elif hero.time < 35:
item = hero.findNearestItem()
if item.type == "coin" and item.value == 2:
hero.moveXY(item.pos.x, item.pos.y)
pass
# After 35 seconds, attack again!
else:
hero.attack(enemy)
pass
I forgot about CodeCombat and have never finished Keeping Time, I am still stuck
# Use your new skill to choose what to do: hero.time
while True:
# If it's the first 10 seconds, attack.
if hero.time < 10:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
pass
# Else, if it's the first 35 seconds, collect coins.
elif hero.time < 35:
item = hero.findNearestItem()
if and item.value == 2
hero.moveXY(item.pos.x, item.pos.y)
pass
# After 35 seconds, attack again!
else:
hero.attack(enemy)
pass
# Use your new skill to choose what to do: hero. time
while True:
# If it's the first 10 seconds, attack.
if hero.time < 10:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
pass
# Else, if it's the first 35 seconds, collect coins.
elif hero.time < 35:
item = hero.findNearestItem()
if item and item.value == 2 :
hero.moveXY(item.pos.x, item.pos.y)
pass
# After 35 seconds, attack again!
else:
hero.attack(enemy)
pass
# Use your new skill to choose what to do: hero.time
while True:
# If it's the first 10 seconds, attack.
if hero.time < 10:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
pass
# Else, if it's the first 35 seconds, collect coins.
elif hero.time > 10 and hero.time < 35:
item = hero.findNearestItem()
if item and item.value == 2 :
hero.moveXY(item.pos.x, item.pos.y)
pass
# After 35 seconds, attack again!
else:
hero.attack(enemy)
pass
item, which calls the hero.findNearestItem() function, returns the nearest item. If the nearest item is not a silver coin, the hero will do nothing. That being said, there are two apparent solutions to the problem. First, you could remove the item.value == 2 condition. Or, you could use a for-loop (or a while-loop) to iterate over the array of items and move to any item in the array with a value of 2.